I remember the times when I was modding Minecraft. There was a function that was called when a neighboring node was changing (digged, placed a.s.o.). It would be useful to have something like this in MT.
What could be done with this?
- Nodes that can only exist when other nodes are near, like doors.
- Nodes that should update something, for example liquid flow, when something in their environment changed.
- Nodes that adjust their shape according to the environment.
Advantages:
- Many ABM's would be obsolete.
-> CPU / memory / performance improvement!
- Could prevent some -b-u-g-s- features.
When mods need sort of a "temporary ABM", something behaving like an ABM but ending when certain conditions are met and activated on a changing neighbor, they can use timers (minetest.after()), this has already been implemented and works.
EDIT: Hey, there are even node timers!
My suggestion:
in node definition:
on_neighborchange=function(pos, node, neighborpos, player)
- neighborpos is the position of the node that changed.
- the given player digged/placed the node, can be nil.
- minetest.set_node() does not call this function.
- VoxelManip operations do not call this function.
- The return value is used to determine further actions:
> true: the neighbors of this node should be notified too because something changed
> other: do nothing.
- introduce another function:
minetest.notify_neighbors(pos, player)
to manually trigger neighbor updates.
(player is just passed to the on_neighborchange function)