Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipe:clear_ingredients error #143

Open
kryzeth opened this issue Jul 23, 2019 · 5 comments
Open

Recipe:clear_ingredients error #143

kryzeth opened this issue Jul 23, 2019 · 5 comments
Assignees
Labels

Comments

@kryzeth
Copy link

kryzeth commented Jul 23, 2019

So the function Recipe:clear_ingredients checks only for self.normal, and then performs actions on self.normal and self.expensive, without checking for self.expensive, causing an error if used on any recipes that are only defined by normal.

I've recently run into this issue when attempting to fix this error in my Reverse Factory mod.

It's having an error with another mod that converts all of its recipes to normal variants, without defining an expensive variant. And partway through my reverse recipe code, after duplicating a recipe and copying the ingredients to its results table, I have a call to clear_ingredients(), which now causes an error.

[original text regarding how to overwrite and add functions to the local Recipe variable removed for brevity]

@kryzeth
Copy link
Author

kryzeth commented Jul 23, 2019

Okay, I figured out how to overwrite functions (just redefining them the same way it's written in the stdlib code, for example:
function Recipe:clear_ingredients()
[insert new logic here]
end

I assume you can add new functions in a similar way. So just wanted to mention the issue also exists in Recipe:set_enabled, and Data:copy, and probably in some of the Data and Technology functions as well.

Is this something I should just overwrite on my end, or something that you plan to adjust from your end?

@Nexela Nexela self-assigned this Jul 24, 2019
@Nexela Nexela added the bug label Jul 24, 2019
@Nexela
Copy link
Collaborator

Nexela commented Jul 24, 2019

Wellllllllllllllll if you have fixed versions I would gladly look at them :)

@kryzeth
Copy link
Author

kryzeth commented Jul 24, 2019

Lmao, well the changes aren't all that spectacular. This is all I've needed to change to make the functions I have in Reverse Factory work.

Although if you wanted, I could go through and fix all the little (but non-error causing) issues I've been having with Stdlib, like set_enabled not working on normal/expensive variants, and similar edge cases.

Basically half of my Reverse Factory code can use the stdlib to shorten code, and the other half (dealing with normal/expensive) has to use the original long form version of the code lol.

But for the most part, it's just using repeated if-then-ends, instead of if-then-elseif-then-end, so if any of the properties apply to the recipe, modify them.

@Nexela
Copy link
Collaborator

Nexela commented Jul 24, 2019

Well my goal is to have normal and expensive work correctly with the shorter code

and finish the results() stuff. but its the nightmare of dealing with multiple ways to define results being the off putting factor..

And by all means if you have come across any little (even non error causing issues) I will gladly accept pull requests to fix them!

@kryzeth
Copy link
Author

kryzeth commented Jul 24, 2019

Alright then, I'll get started on this tomorrow. And hopefully figure out how to do things like pull requests lol.

I'm pretty sure I've done a good portion of similar code already... like I had to write an entire removeResults function to clear out result, results, and main_product, from the base recipe, normal, and expensive parts of the recipe.

I wouldn't mind if there were a set_hidden function as well, similar to set_enabled... and if there were some way to define a series of fields on the base recipe, normal, and expensive part of the recipe, that would seriously prune out a lot of code on my end.

All of my reverse recipes need to have enabled = true, hidden = true, and allow_decomposition = false, and I can use set_fields to apply this to the simple recipes, but if they are normal/expensive, I have to reapply these fields manually. Anyways, until tomorrow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants