Minetest-WorldEditAdditions/worldeditadditions_commands/commands/meta
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
..
airapply.lua more crash fixes 2022-09-19 19:42:22 +01:00
ellipsoidapply.lua Upgrade meta commands 2022-09-18 22:37:26 +01:00
for.lua run_command: implement support for async functions. 2024-10-17 01:54:32 +01:00
init.lua Added //nodeapply to filter cmd changes via a nodelist 2023-11-26 22:20:05 +00:00
listentities.lua add //listentities 2023-08-01 00:07:10 +01:00
macro.lua Update minetest.chatcommands → minetest.registered_chatcommands 2023-07-09 19:49:38 +01:00
many.lua Update minetest.chatcommands → minetest.registered_chatcommands 2023-07-09 19:49:38 +01:00
multi.lua Update minetest.chatcommands → minetest.registered_chatcommands 2023-07-09 19:49:38 +01:00
nodeapply.lua //nodeapply: fix crash on unknown node name 2023-12-15 03:11:40 +00:00
noiseapply2d.lua Upgrade meta commands 2022-09-18 22:37:26 +01:00
subdivide.lua Update minetest.chatcommands → minetest.registered_chatcommands 2023-07-09 19:49:38 +01:00