Open kryzeth opened 5 years ago
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?
Wellllllllllllllll if you have fixed versions I would gladly look at them :)
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.
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!
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!
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]