add /eval_reset to clear your personal environment
This commit is contained in:
parent
15ef934e3c
commit
b91dc915fd
14
README.md
14
README.md
@ -1,7 +1,11 @@
|
|||||||
## Adds `/eval` command
|
## 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.
|
`/eval` takes lua code as argument and executes it. It will echo your
|
||||||
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]`).
|
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:
|
## Some nice features:
|
||||||
### Expression/statement agnostic
|
### 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.
|
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`
|
||||||
|
13
init.lua
13
init.lua
@ -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(
|
core.register_on_player_receive_fields(
|
||||||
function(player, formname, fields)
|
function(player, formname, fields)
|
||||||
if formname == "cmd_eval:dump" or formname == "cmd_eval:input" then
|
if formname == "cmd_eval:dump" or formname == "cmd_eval:input" then
|
||||||
|
Loading…
Reference in New Issue
Block a user