-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add Lua function to remove a registered decoration, fix #12881 #14361
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
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for the PR. The implementation looks reasonable. clearByName
should probably be called removeByName
/ eraseByName
to be consistent with C++ terminology.
Besides docs, it would be useful to have some basic testing code for this in devtest.
(At a glance it looks like objdef.(h|cpp)
should be refactored to use a std::unordered_map
, but that is out of scope for this PR.)
how much more complicated to add support for removing ore registration/biome? i understand biome might be harder since decorations and ores can be bound to biomes. just mentioning it since the three make up the most issues for mods (takes one bad apple to ruin the bunch) |
Potential conflict with #14191. |
That's correct, yes, and I think sfence has found the correct naming scheme with |
There is a problem with biome IDs. In the time of decoration/ore registration, the biome names are translated to biome ids on C++ side. So, every change in biomes can make them invalid. But, if we want to prevent the need for reregistration, it is probably the best way to use a similar schema as is used in register_abm/lbm. This means that the register/unregister function in Lua will change only with Lua tables and real registration on C++ side will be done at the same time as abm/lbm registration (after |
This seems like the best approach. I especially like that this curtails the complexity of the C++ code and gives modders decent flexibility. |
Ok, I update #14191 soon. |
Add compact, short information about your PR for easier understanding:
ObjDefManager::clearByName(const std::string &name)
and exposing it via the Lua functionclear_decoration(name)
.minetest.clear_craft()
. In my specific use case, the mod "moonflowers" depends on "default" to define nodes on which to place the flowers on. I want to decouple the mod from default by exposing a method to re-register the flower decoration while allowing overrides of.place_on
and/or.biomes
.To do
This PR is Ready for Review.
How to test
minetest.clear_decoration("default:dry_shrub")