Minetest-WorldEditAdditions/worldeditadditions_core/core
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
..
entities post_marker_wall: @module → @namespace 2023-12-31 17:08:36 +00:00
integrations Begin rewriting worldeditadditions_core 2022-05-16 23:32:40 +01:00
command_exists.lua Bugfix: don't error out on //flora → //bonemeal alias if bonemeal mod isn't installed 2023-12-13 22:15:27 +00:00
fetch_command_def.lua update more comments 2023-08-03 14:37:05 +01:00
pos.lua core/pos: implement set_multi as a convenient alternative to multiple set() calls 2024-09-30 22:01:22 +01:00
pos_marker_manage.lua pos_marker_manage: fix crash 2024-09-13 02:54:38 +01:00
pos_marker_wall_manage.lua Does this finally fix the zombie marker wall bug? 2023-08-19 00:58:58 +01:00
register_alias.lua update more comments 2023-08-03 14:37:05 +01:00
register_command.lua run_command: implement support for async functions. 2024-10-17 01:54:32 +01:00
run_command.lua run_command: implement support for async functions. 2024-10-17 01:54:32 +01:00
safe_function.lua fix busted error 2024-10-14 20:59:42 +01:00
safe_region.lua update more comments 2023-08-03 14:37:05 +01:00