From 74377c72850d0a3a69f451bc4f6e7f9fb6b7f72c Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 17 Oct 2024 02:40:07 +0100 Subject: [PATCH] safe_function: update docs, add todo ref implementing `wea_core.safe_after()` --- worldeditadditions_core/core/safe_function.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/worldeditadditions_core/core/safe_function.lua b/worldeditadditions_core/core/safe_function.lua index 7808bcc..150e4fb 100644 --- a/worldeditadditions_core/core/safe_function.lua +++ b/worldeditadditions_core/core/safe_function.lua @@ -64,6 +64,12 @@ end --- Calls the given function `fn` with the UNPACKED arguments from `args`, catching errors and sending the calling player a nice error message with a report link. -- -- WARNING: Do NOT nest `safe_function()` calls!!! +-- +-- You do not need to call this function normally. For commands registered via `worldeditadditions_core.register_command`, your `parse()`, `nodes_needed()`, and `func()` functions are all protected with this function automatically. +-- +-- You may need to call this function in an async function - NOT in the main `func()`, but inside every `minetest.after()` call. This is because an async jump like that provided by `minetest.after()` will cause the original function to end, thus ending the `safe_function()` sandbox. +-- +-- TODO implement `wea_core.safe_after()`. -- @param fn function The function to call -- @param args table The table of args to unpack and send to `fn` as arguments -- @param player_name string|nil The name of the player affected. If nil then no message is sent to the player.