solarus-games / solarus

This repository was moved to GitLab: https://gitlab.com/solarus-games/solarus
http://www.solarus-games.org
Other
712 stars 133 forks source link

Custom entity on_interaction #1049

Closed wrightmat closed 7 years ago

wrightmat commented 7 years ago

If a custom entity has an on_interaction function defined, but that particular instance of the entity (say an NPC) also has on_interaction defined in the map script, the custom entity function never executes - only the map one does. Not sure if this is the intended behavior, but I would really like the custom entity one to run. If only one can execute, the custom entity function should be preferred, as the map function could easily be run from here if it exists.

Diarandor commented 7 years ago

I think this is not an engine bug: If you are defining that event for the custom entity in the map script, then you are overriding the one defined in the custom entity script (only for that instance). This is just how Lua works, so nothing to do with Solarus.

If you want to execute only the one in the custom entity script, then do not re-define it in the map script again (check if it is already defined). If you want to use both, which is also possible, just use the multi events script made by @christopho.

wrightmat commented 7 years ago

I'm okay with this explanation and solution. If @christopho agrees, he can close the issue :)