forked from your-land-mirror/cmd_eval
better handle quit(pause) and resume via formspec
This commit is contained in:
parent
30af38c5a7
commit
8a2bb20925
43
init.lua
43
init.lua
@ -426,30 +426,31 @@ core.register_on_player_receive_fields(
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not (fields.resume or fields.send) then
|
if fields.resume or fields.send or fields.quit then
|
||||||
return true
|
local last = last_coro_by_player[player_name]
|
||||||
end
|
if not last then
|
||||||
|
return true -- nothing to resume
|
||||||
|
end
|
||||||
|
|
||||||
local last = last_coro_by_player[player_name]
|
local ok, res, show_res
|
||||||
if not last then
|
if formname == "cmd_eval:input" and fields.send then
|
||||||
return true -- nothing to resume
|
local input = fields.input or ""
|
||||||
end
|
ok, res = resume_coroutine(player_name, input)
|
||||||
|
show_res = true
|
||||||
|
elseif formname == "cmd_eval:dump" and fields.resume then
|
||||||
|
ok, res = resume_coroutine(player_name)
|
||||||
|
show_res = true
|
||||||
|
end
|
||||||
|
|
||||||
local ok, res
|
if show_res then
|
||||||
if formname == "cmd_eval:input" then
|
if ok then
|
||||||
local input = fields.input or ""
|
core.chat_send_player(player_name, res)
|
||||||
ok, res = resume_coroutine(player_name, input)
|
else
|
||||||
else
|
-- not sure if we need to handle errors here in some way?
|
||||||
ok, res = resume_coroutine(player_name)
|
core.chat_send_player(player_name, res)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ok then
|
|
||||||
core.chat_send_player(player_name, res)
|
|
||||||
else
|
|
||||||
-- not sure if we need to handle errors here in some way?
|
|
||||||
core.chat_send_player(player_name, res)
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return -- did not match known FS names
|
return -- did not match known FS names
|
||||||
|
Loading…
Reference in New Issue
Block a user