set d_end if minetest.close_formspec is used in a function
This commit is contained in:
parent
a03d2895d0
commit
26db498afe
@ -45,6 +45,7 @@ yl_speak_up.check_one_npc_for_migration = function(dialog, pname, n_id)
|
||||
-- iterate over all options
|
||||
for o_id, o in pairs(d.d_options) do
|
||||
if(o_id and o and o.o_results) then
|
||||
local has_close_formspec = false
|
||||
local dialog_results = {}
|
||||
-- iterate over all results
|
||||
for r_id, r in pairs(o.o_results) do
|
||||
@ -52,6 +53,11 @@ yl_speak_up.check_one_npc_for_migration = function(dialog, pname, n_id)
|
||||
table.insert(dialog_results, r_id)
|
||||
elseif(r.r_type == "function") then
|
||||
c_effect_exec_lua = c_effect_exec_lua + 1
|
||||
-- if the formspec is closed, we need to use the
|
||||
-- target dialog d_end
|
||||
if(string.find(r.r_value , "minetest.close_formspec")) then
|
||||
has_close_formspec = true
|
||||
end
|
||||
elseif(r.r_type == "move") then
|
||||
c_effect_move_player = c_effect_move_player + 1
|
||||
elseif(r.r_type == "give_item") then
|
||||
@ -70,6 +76,23 @@ yl_speak_up.check_one_npc_for_migration = function(dialog, pname, n_id)
|
||||
if(pname) then
|
||||
minetest.chat_send_player(pname, msg)
|
||||
end
|
||||
-- sometimes we need d_end because minetest.close_formspec in
|
||||
-- an effect of type "function" is not enough
|
||||
elseif(has_close_formspec) then
|
||||
local d_old = ""
|
||||
for r_id, r in pairs(o.o_results) do
|
||||
if(r.r_type == "dialog" and r.r_value ~= "d_end") then
|
||||
d_old = r.r_value
|
||||
r.r_value = "d_end"
|
||||
end
|
||||
end
|
||||
yl_speak_up.save_dialog(n_id, dialog)
|
||||
local msg = "ERROR: Dialog "..
|
||||
tostring(d_id)..", option "..tostring(o_id)..
|
||||
", uses minetest.close_formspec in its lua code "..
|
||||
"but "..tostring(d_old).." instead of d_end as "..
|
||||
"target dialog. Fixing."
|
||||
minetest.chat_send_player(pname, msg)
|
||||
end
|
||||
end
|
||||
if(o_id and o and o.o_prerequisites) then
|
||||
|
Loading…
Reference in New Issue
Block a user