You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, registering a callback for the MC_EXECUTE_CMD does not allow for an additional argument to filter by what command used. Mods registering to this callback should be able to optionally filter by the command being used.
Example:
-- This adds a callback which is only executed if the "cmd" argument to the callback matches "spawn_item"
mod:AddCallback(ModCallbacks.MC_EXECUTE_CMD, debug_spawn_item, "spawn_item")
This would eliminate the need for mods using Repentogon to include if cmd == "spawn_item" at the beginning of every command's callback. It would also be a minor performance save as the comparison would be made before executing the Lua callback.
The text was updated successfully, but these errors were encountered:
It will NOT be a saving as optional arguments checks are done within Lua ever since the official callback rework and due to the function not being called that often for it to be an issue
I personally don't think it's THAT big of an issue to do the check yourself? Though I am not entirely opposed to the idea of this little QoL thingy.
It will NOT be a saving as optional arguments checks are done within Lua ever since the official callback rework and due to the function not being called that often for it to be an issue
Fair enough.
I still think that adding something to do a comparison for you makes sense, considering that comparison is probably made 99.9% of the time the callback is used,
It also helps prevent bugs. I had to fix an issue with my mod where any use of any console command would trigger all my debug commands.
Currently, registering a callback for the
MC_EXECUTE_CMD
does not allow for an additional argument to filter by what command used. Mods registering to this callback should be able to optionally filter by the command being used.Example:
This would eliminate the need for mods using Repentogon to include
if cmd == "spawn_item"
at the beginning of every command's callback. It would also be a minor performance save as the comparison would be made before executing the Lua callback.The text was updated successfully, but these errors were encountered: