Minetest-WorldEditAdditions/worldeditadditions_commands
Starbeamrainbowlabs 1ae48f3a52
run_command: implement support for async functions.
Also update //for to make use of this new functionality.

//subdivide is still on the todo list.

The new functionality works by adding the new property `async = false` to command definition tables registered via wea_core.register_command()`. When `true`, if and only if the command's MAIN FUNC ONLY returns no values at all then it will consider an async operation to be in progress.

This delays `run_command` from emitting the `post-execute` event on `wea_core`.

Additionally, all async commands have a callback function injected as the first argument to their main `func` (ref main cmd definition table). This callback function -- if no arguments are returned by the main `func` -- must be called once the async operation is complete with same args you would normally return from `func` -- that is `success, result_message`. These will then be handled as normal and sent to the player as appropriate, as well as finally emitting the `post-execute` event.

BUG: There is a potential issue in this implementation, in that if i.e. `minetest.after()` is used to delay async execution then this will break out of the `xpcall()` protection in place to prevent crashes. To this end, if you implement an async function you need to be very careful, and do a manual `wea_core.safe_function()` call yourself!
2024-10-17 01:54:32 +01:00
..
commands run_command: implement support for async functions. 2024-10-17 01:54:32 +01:00
doc start working on converting everything to the new utils location 2022-09-18 17:59:57 +01:00
aliases.lua Alias //napply to //nodeapply 2024-05-25 14:48:38 +01:00
init.lua added //test 2024-10-13 13:54:02 -07:00
mod.conf core: implement fetch_command_def 2022-05-19 02:31:01 +01:00
player_notify_suppress.lua //subdivide: Tidy up output 2020-06-26 21:15:13 +01:00