-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add ExchangeClone support. #335
Conversation
This is also a problem for #328, so it would be preferable to find a way to fix the cause than add more glue code. Switching to use |
I tried that first. My guess is that Edit: I just checked, and that is how it works. Using this code: minetest.after(0.1, function(...) minetest.log("After") end)
minetest.register_on_mods_loaded(function(...) minetest.log("Loaded") end) "Loaded" appears before "After" every time, as far as I can tell (I tried it a few times, sometimes closing Minetest in between, in case that mattered). |
Yes, the From the documentation:
Now that I look at it, |
one possibility to solve this would be to intercecpt all -- store old ref
local old_register_recipe = technic.register_recipe
-- overwrite with interceptor
function technic.register_recipe(typename, data)
-- your hook
your_custom_code()
-- old function
return old_register_recipe(typename, data)
end if everyone would implement it that way it should be compatible to each other (except if the parameter count changes) but yeah: it is just more glue, not a proper solution 🤷 |
The thing about that is... I'd have to override the function AFTER it gets defined but BEFORE everything else in the technic mod runs. That's why I did it the way I did it.
|
I'm going to have a go at fixing it, and also try to implement group support while I'm at it. |
why not just expose a list of registered recipes that's filled when |
It would be nice if this could be resolved before I publish the next ExchangeClone release. |
There's currently 2 failures for required check, currently it is not possible to merge this: technic/machines/register/recipes.lua:99:121: line is too long (129 > 120)
technic/machines/register/recipes.lua:104:3: accessing undefined variable exchangeclone First is simple: line too long, make it shorter or break into multiple lines. Undefined variable should be fixed by adding Lines 22 to 32 in f1b9928
|
@@ -96,7 +96,13 @@ local function register_recipe(typename, data) | |||
end | |||
end | |||
|
|||
-- Checks for "zzzz_exchangeclone_crafthook" mod so that it won't crash with older versions of ExchangeClone which don't have it. | |||
local has_exchangeclone = minetest.get_modpath("zzzz_exchangeclone_crafthook") |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
I fixed those things (and updated the mod name to the correct one, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is all it takes fine for me, after all it is just simple and self contained load time only compatibility feature which can be easily cleaned up / refactored later if / when there's more mods requiring somewhat similar compatibility stuff.
My mod ExchangeClone calculates an energy value for every item based on crafting recipes. I thought it would be a good idea for it to be able to use Technic's crafting methods, but I discovered that the way Technic waits until everything was loaded before populating
technic.recipes
made that difficult. This is an incredibly simple addition that calls a function every time a recipe is registered.I have tested with and without ExchangeClone enabled. I doubt it could possibly mess anything up.
In case you're wondering,
zzzz_exchangeclone_crafthook
is named the way it is because Minetest loads mods in reverse alphabetical order.The function this calls can be found here in the dev branch.