forked from Sokomine/yl_speak_up
make delete precondition work
This commit is contained in:
parent
b0f141b09d
commit
ce7877bc2b
@ -319,7 +319,33 @@ yl_speak_up.input_fs_edit_preconditions = function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
|
||||
-- TODO: make delete work
|
||||
-- delete precondition
|
||||
if(fields.delete_prereq) then
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
if(dialog and dialog.n_dialogs
|
||||
and p_id
|
||||
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
|
||||
-- actually delete the prerequirement
|
||||
dialog.n_dialogs[d_id].d_options[o_id].o_prerequisites[ p_id ] = nil
|
||||
-- record this as a change, but do not save do disk yet
|
||||
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||
"Dialog "..tostring(d_id)..": ".."Pre(C)ondition "..tostring(p_id)..
|
||||
" deleted for option "..tostring(o_id)..".")
|
||||
-- TODO: when trying to save: save to disk as well?
|
||||
-- show the new/changed precondition
|
||||
-- go back to the edit option dialog (after all we just deleted the prerequirement)
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
input_to = "yl_speak_up:edit_preconditions",
|
||||
formspec = "size[6,2]"..
|
||||
"label[0.2,0.5;Pre(C)ondition \""..
|
||||
minetest.formspec_escape(tostring(p_id))..
|
||||
"\" has been deleted.]"..
|
||||
"button[1.5,1.5;2,0.9;back_from_delete_precondition;Back]"})
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if(fields.select_block_pos) then
|
||||
minetest.chat_send_player(pname,
|
||||
|
Loading…
Reference in New Issue
Block a user