Minetest-WorldEditAdditions/worldeditadditions_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
..
core run_command: implement support for async functions. 2024-10-17 01:54:32 +01:00
textures initial pos marker wall for +x only 2023-06-27 21:45:48 +01:00
utils split_shell: use @example 2024-10-17 00:34:42 +01:00
init.lua Merge branch 'feature/pcall-protection' into dev 2024-10-15 20:15:17 +01:00
mod.conf movetool, //speed: add optdepend on pova 2023-12-30 13:12:10 +00:00
README.md Implement run_command, but it's not quite finished yet 2022-05-17 01:03:58 +01:00

worldeditadditions_core

This mod's purpose is to provide a solid base upon which the rest of WorldEditAdditions can function. Once it is complete, we will be able to mark our dependency on worldedit itself optional. To get to that point though will still require a significant effort in implementing enhanced versions of all existing WorldEdit commands. If you've got some free time and a great idea for a command, please do open a pull request! :D

In short, worldeditadditions_core is a reimplementation of a number of underlying parts of the worldedit engine. Parts of worldeditadditions_core are likely to look very similar to parts of WorldEdit - this is because inspiration was taken from Uberi/WorldEdit when implementing worldeditadditions_core.