forked from Sokomine/yl_speak_up
63 lines
2.0 KiB
Lua
63 lines
2.0 KiB
Lua
|
|
yl_speak_up.input_fs_edit_effects = function(player, formname, fields)
|
|
if(not(player)) then
|
|
return
|
|
end
|
|
local pname = player:get_player_name()
|
|
-- what are we talking about?
|
|
local n_id = yl_speak_up.speak_to[pname].n_id
|
|
local d_id = yl_speak_up.speak_to[pname].d_id
|
|
local o_id = yl_speak_up.speak_to[pname].o_id
|
|
|
|
-- this only works in edit mode
|
|
if(not(n_id) or yl_speak_up.edit_mode[pname] ~= n_id) then
|
|
return
|
|
end
|
|
|
|
-- go back to the edit option dialog
|
|
yl_speak_up.show_fs(player, "edit_option_dialog",
|
|
{n_id = n_id, d_id = d_id, o_id = o_id, caller="edit_effects"})
|
|
end
|
|
|
|
yl_speak_up.get_fs_edit_effects = function(player, table_click_result)
|
|
if(not(player) or not(table_click_result)) then
|
|
return ""
|
|
end
|
|
local pname = player:get_player_name()
|
|
-- what are we talking about?
|
|
local n_id = yl_speak_up.speak_to[pname].n_id
|
|
local d_id = yl_speak_up.speak_to[pname].d_id
|
|
local o_id = yl_speak_up.speak_to[pname].o_id
|
|
|
|
-- this only works in edit mode
|
|
if(not(n_id) or yl_speak_up.edit_mode[pname] ~= n_id) then
|
|
return "size[1,1]label[0,0;You cannot edit this NPC.]"
|
|
end
|
|
|
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
|
if(not(dialog) or not(dialog.n_dialogs)
|
|
or not(dialog.n_dialogs[d_id])
|
|
or not(dialog.n_dialogs[d_id].d_options)
|
|
or not(dialog.n_dialogs[d_id].d_options[o_id])) then
|
|
return "size[4,1]label[0,0;Dialog option does not exist.]"
|
|
end
|
|
|
|
local results = dialog.n_dialogs[d_id].d_options[o_id].o_results
|
|
if(not(results)) then
|
|
results = {}
|
|
end
|
|
-- which precondition has the player selected?
|
|
local sorted_key_list = yl_speak_up.sort_keys(results)
|
|
local selected = minetest.explode_table_event(table_click_result)
|
|
-- use "new" if nothing fits
|
|
local r_id = "new"
|
|
if((selected.type == "CHG" or selected.type == "DLC")
|
|
and selected.row <= #sorted_key_list) then
|
|
r_id = sorted_key_list[ selected.row ]
|
|
end
|
|
|
|
minetest.chat_send_player("singleplayer","input: "..minetest.serialize(table_click_result))
|
|
return "size[4,1.5]label[0,0;Formspec: edit effect\n-> "..tostring(r_id).."]"..
|
|
"button[1,1.0;1,1.0;back;Back]"
|
|
end
|