hkzorman / advanced_npc

Advanced NPC for Minetest, using mobs_redo API
Other
17 stars 5 forks source link

Function references for actions get unloaded frequently causing crashes #9

Closed hkzorman closed 7 years ago

hkzorman commented 7 years ago

While I'm not 100% this is the cause of the bug, I'm quite certain that function references inside the Lua table of a Lua Entity get removed on unload/load of entities and are completely unreliable. Every time this function references get nil, Minetest crashes with a nil exception.

The proposed fix for this bug is to implement a execute function in actions.lua that takes a constant value and executes the corresponding function. These constants will be called "commands" and they are going to be defined in actions.lua. These commands are going to be stored in the queue of the Lua Entity instead of the direct function reference.

hkzorman commented 7 years ago

1d1a56592bd4525fb21da3ae70d74b838f8b3aa0