the reset cmd #7

Merged
whosit merged 2 commits from your-land-mirror/cmd_eval:master into master 2025-04-05 10:40:18 +02:00
2 changed files with 26 additions and 3 deletions

View File

@ -1,7 +1,11 @@
## Adds `/eval` command
`/eval` takes lua code as argument and executes it. It will echo your command and show it's output and returned value.
Each player gets their own "global" environment so they can't interfere with other user's envs by accident (exposed as `cmd_eval.e[player_name]`).
`/eval` takes lua code as argument and executes it. It will echo your
command and show it's output and returned value. Each player gets
their own "global" environment so they can't interfere with other
user's envs by accident (exposed as `cmd_eval.e[player_name]`).
Type `/eval help` to see the built-in help.
## Some nice features:
### Expression/statement agnostic
@ -230,3 +234,9 @@ You can still resume it by typing `/eval_resume <text>` - the argument
text will be passed instead of the context of text area of the formspec.
### Resetting your personal environment
If your environment gets messed up, or you just want to get rid of the
variables you've stored, you can type:
`/eval_reset`

View File

@ -415,7 +415,7 @@ core.register_chatcommand("eval_resume",
description = "Resume previous command",
privs = { server = true },
func = function(player_name, param)
core.log("action", string.format("[cmd_eval][%s] %s resumed previous command", coro_cc, player_name, dump(param)))
core.log("action", string.format("[cmd_eval] %s resumed previous command", player_name, dump(param)))
core.chat_send_player(player_name, "* resuming...")
-- it's possible to send the string back to the coroutine through this
@ -425,6 +425,19 @@ core.register_chatcommand("eval_resume",
)
core.register_chatcommand("eval_reset",
{
description = "Restore your environment by clearing all variables you assigned",
privs = { server = true },
func = function(player_name, param)
core.log("action", string.format("[cmd_eval] %s reset their environmet", player_name, dump(param)))
api.e[player_name] = nil
return true, orange_fmt("* Your environment has been reset to default.")
end
}
)
core.register_on_player_receive_fields(
function(player, formname, fields)
if formname == "cmd_eval:dump" or formname == "cmd_eval:input" then