mirror of
https://gitea.your-land.de/whosit/cmd_eval.git
synced 2025-06-21 00:58:01 +02:00
better handle cases when "nothing" is returned
This commit is contained in:
parent
e819fbe5d9
commit
44d24e549d
8
init.lua
8
init.lua
@ -153,8 +153,12 @@ core.register_chatcommand("eval",
|
||||
local n = select("#", ...)
|
||||
local res = {...}
|
||||
ok = res[1]
|
||||
-- API calls can sometimes return literal "nothing", so `n` can be 1
|
||||
if n <= 2 then
|
||||
if n == 1 then
|
||||
-- In some cases, calling a function can return literal "nothing":
|
||||
-- + Executing loadstring(`x = 1`) returns "nothing".
|
||||
-- + API calls also can sometimes return literal "nothing" instead of nil
|
||||
return ok and "Done." or "Failed without error message."
|
||||
elseif n == 2 then
|
||||
-- returned single value or error
|
||||
env._ = res[2] -- store result in "_" per-user "global" variable
|
||||
if ok then
|
||||
|
Loading…
Reference in New Issue
Block a user