dialog effects cannot be deleted or edited anymore

This commit is contained in:
Sokomine 2021-06-27 17:43:14 +02:00
parent 2544fdc0c9
commit 46f5232d49

View File

@ -175,6 +175,11 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
return
end
if(fields.back_from_cannot_be_edited) then
yl_speak_up.show_fs(player, formspec_input_to, x_id)
return
end
-- delete precondition
if(fields.delete_element) then
local dialog = yl_speak_up.speak_to[pname].dialog
@ -183,6 +188,16 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
and dialog.n_dialogs[d_id]
and dialog.n_dialogs[d_id].d_options
and dialog.n_dialogs[d_id].d_options[o_id]) then
local old_elem = dialog.n_dialogs[d_id].d_options[o_id][ element_list_name ][ x_id ]
if(id_prefix == "r_" and old_elem.r_type == "dialog") then
yl_speak_up.show_fs(player, "msg", {
input_to = "yl_speak_up:"..formspec_input_to,
formspec = "size[9,2]"..
"label[0.2,0.5;Effects of the type \"dialog\" cannot be deleted.\n"..
"Use the edit options or dialog menu to change the target dialog.]"..
"button[1.5,1.5;2,0.9;back_from_cannot_be_edited;Back]"})
return
end
-- actually delete the element
dialog.n_dialogs[d_id].d_options[o_id][ element_list_name ][ x_id ] = nil
-- record this as a change, but do not save do disk yet
@ -875,6 +890,13 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
-- does kind of the opposite than the saving of values starting in line 323 of this file
if(x_id ~= "new" and data.what == 1 and elements[ x_id ]) then
local e = elements[ x_id ]
if( id_prefix == "r_" and e[ "r_type" ] == "dialog") then
-- dialog effects cannot be edited this way
return "size[9,2]"..
"label[0.2,0.5;Effects of the type \"dialog\" cannot be edited this way.\n"..
"Use the edit options or dialog menu to change the target dialog.]"..
"button[1.5,1.5;2,0.9;back_from_cannot_be_edited;Back]"
end
data.what = table.indexof(values_what, e[ id_prefix.."type" ])
if(data.what == -1) then
data.what = 1