add d_end in migration script when necessary

This commit is contained in:
Sokomine 2023-02-26 22:41:32 +01:00
parent 56b832d9d1
commit bd67fa2ea7

View File

@ -79,20 +79,33 @@ yl_speak_up.check_one_npc_for_migration = function(dialog, pname, n_id)
-- sometimes we need d_end because minetest.close_formspec in -- sometimes we need d_end because minetest.close_formspec in
-- an effect of type "function" is not enough -- an effect of type "function" is not enough
elseif(has_close_formspec) then elseif(has_close_formspec) then
local found = false
local d_old = "" local d_old = ""
for r_id, r in pairs(o.o_results) do for r_id, r in pairs(o.o_results) do
if(r.r_type == "dialog" and r.r_value ~= "d_end") then if(r.r_type == "dialog" and not(found)) then
d_old = r.r_value d_old = r.r_value
r.r_value = "d_end" r.r_value = "d_end"
found = true
end end
end end
yl_speak_up.save_dialog(n_id, dialog) -- if there is no dialog option yet: create one
local msg = "ERROR: Dialog ".. if(not(found)) then
tostring(d_id)..", option "..tostring(o_id).. local future_r_id = yl_speak_up.add_new_result(
", uses minetest.close_formspec in its lua code ".. dialog, d_id, o_id)
"but "..tostring(d_old).." instead of d_end as ".. o.o_results[future_r_id] = {
"target dialog. Fixing." r_id = future_r_id,
minetest.chat_send_player(pname, msg) r_type = "dialog",
r_value = "d_end"}
end
if(d_old ~= "d_end") then
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 end
end end
if(o_id and o and o.o_prerequisites) then if(o_id and o and o.o_prerequisites) then