-
Notifications
You must be signed in to change notification settings - Fork 2k
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 minetest.override_entity() #6909
Comments
I don't know if all of these could be solved with on_step callbacks, but I agree this could be useful. An example would be having liquid flow or conveyor belts move items around. |
Having an |
The '__builtin:item' does have already an |
Adding another callback is not really a solution. You'll have the same problem, you'll have to override this new callback, and to make sure you don't conflict you should call the old callback inside your own callback. At the moment there's no |
Primary I search for any way to change the builtin behaviour. Usually it is enoug to redefine the functionality once in subgame. If multiple mods needs to redefine the behaviour, it is possible to create an "on_step = local old_onstep + new_onstep" wrapper chain, like sometimes seen for node's on_use. If really a lot of mods requires them, an builtin_item_manager mod can be written that redefines once the builtin's on_step and the provides the register_item_entity_on_step() function or something like. New idea is to do it like the minetest_game abm for lava-cooling
This way it is possible just to replace the core.builtin_item_on_step in other mods But I prefer the minetest.override_entity() for now (like exitsitng minetest.override_item()) because of the most flexibility |
👎 You should use override entity and wrap around the old on step |
Should I adjust the initial post to request the minetest.override_entity()? |
You can already override the entity using minetest.registered_entities, but an override_entity method would be nice |
I do not know how the table content minetest.registered_entities is synchronized to the engine, therefore I access such tables read only. To change builtin things an method should exists. I know the way to get the full definition from minetest.registered_entities, modify the method and then re-register using core.register_entity(":__builtin:item" modified_def), but I do not like this way |
This should work:
You don't have to directly write into |
Entities aren't synced to the engine at all, the engine reads the table. The only reason that items are synced with the engine is so they can be sent to clients - entities have object properties binstead |
The "dropped item" entity '__builtin:item' should have an callback in on_step to allow game-specific behaviors like other physics, environment manipulations, light, knock-back, and many others using mods. The best way is a function that is executed before the builtin logic and if the function returns false the builtin logic is skipped. Something like minetest.register_item_entity_on_step(func(obj)) ?
EDIT 2018-05-08: after some discussion the preferred way is to add minetest.override_entity() function that can redefine entity methods without the full re-registration. Like minetest.override_items() does for nodes and items.
The text was updated successfully, but these errors were encountered: