forked from your-land-mirror/yl_speak_up
yl_speak_up.show_what_points_to_this_dialog is now handled by show_fs, and the back button works
This commit is contained in:
parent
fc06ddc8ba
commit
972a1e1e61
@ -342,7 +342,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- show which dialogs point/lead to this_dialog
|
-- show which dialogs point/lead to this_dialog
|
||||||
yl_speak_up.show_what_points_to_this_dialog = function(player, pname, dialog, this_dialog)
|
yl_speak_up.show_what_points_to_this_dialog = function(player, this_dialog)
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
if(not(dialog)
|
if(not(dialog)
|
||||||
or not(dialog.n_dialogs)
|
or not(dialog.n_dialogs)
|
||||||
or not(this_dialog)
|
or not(this_dialog)
|
||||||
@ -350,13 +352,17 @@ yl_speak_up.show_what_points_to_this_dialog = function(player, pname, dialog, th
|
|||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- only show this information when editing this npc
|
||||||
|
if(yl_speak_up.edit_mode[pname] ~= yl_speak_up.speak_to[pname].n_id) then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
local found = {}
|
local found = {}
|
||||||
-- colored lines for the table showing the results
|
-- colored lines for the table showing the results
|
||||||
local res = {}
|
local res = {}
|
||||||
-- iterate over all dialogs
|
-- iterate over all dialogs
|
||||||
for d_id, d in pairs(dialog.n_dialogs) do
|
for d_id, d in pairs(dialog.n_dialogs) do
|
||||||
-- we are looking for dialogs that point here - not the dialog itself
|
-- the dialog itself may have options that point back to the dialog itself
|
||||||
if(d_id ~= this_dialog and d.d_options) then
|
if(d.d_options) then
|
||||||
-- iterate over all options
|
-- iterate over all options
|
||||||
for o_id, o in pairs(d.d_options) do
|
for o_id, o in pairs(d.d_options) do
|
||||||
local r_text = ""
|
local r_text = ""
|
||||||
@ -438,7 +444,6 @@ yl_speak_up.show_what_points_to_this_dialog = function(player, pname, dialog, th
|
|||||||
minetest.colorize("#FFFF00", tostring(#found))..
|
minetest.colorize("#FFFF00", tostring(#found))..
|
||||||
" options/actions/results.").."]")
|
" options/actions/results.").."]")
|
||||||
else
|
else
|
||||||
-- TODO. make turn into alternate_text work
|
|
||||||
table.insert(formspec,
|
table.insert(formspec,
|
||||||
"button[0.2,30.6;56.6,1.2;turn_dialog_into_alternate_text;"..
|
"button[0.2,30.6;56.6,1.2;turn_dialog_into_alternate_text;"..
|
||||||
minetest.formspec_escape("Turn this dialog \""..
|
minetest.formspec_escape("Turn this dialog \""..
|
||||||
@ -474,3 +479,21 @@ yl_speak_up.show_what_points_to_this_dialog = function(player, pname, dialog, th
|
|||||||
return table.concat(formspec, "").."]"
|
return table.concat(formspec, "").."]"
|
||||||
--]]
|
--]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
yl_speak_up.input_fs_show_what_points_to_this_dialog = function(player, formname, fields)
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
if(fields.back_from_show_what_points_here) then
|
||||||
|
-- back to the dialog
|
||||||
|
yl_speak_up.show_fs(player, "talk",
|
||||||
|
{n_id = yl_speak_up.speak_to[pname].n_id,
|
||||||
|
d_id = yl_speak_up.speak_to[pname].d_id})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- works only in edit mode
|
||||||
|
if(yl_speak_up.edit_mode[pname] ~= yl_speak_up.speak_to[pname].n_id) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
|
-- TODO. make turn into alternate_text work
|
||||||
|
minetest.chat_send_player("singleplayer","GREAT! Got input: "..minetest.serialize(fields))
|
||||||
|
end
|
||||||
|
@ -2215,9 +2215,8 @@ yl_speak_up.input_talk = function(player, formname, fields)
|
|||||||
if(fields.show_what_points_to_this_dialog) then
|
if(fields.show_what_points_to_this_dialog) then
|
||||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
local d_id = yl_speak_up.speak_to[pname].d_id
|
local d_id = yl_speak_up.speak_to[pname].d_id
|
||||||
-- TODO: use show_fs here
|
yl_speak_up.show_fs(player, "show_what_points_to_this_dialog",
|
||||||
minetest.show_formspec(pname, "yl_speak_up:show_points_to_dialog",
|
yl_speak_up.speak_to[pname].d_id)
|
||||||
yl_speak_up.show_what_points_to_this_dialog(player, pname, dialog, d_id))
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,6 +71,10 @@ minetest.register_on_player_receive_fields( function(player, formname, fields)
|
|||||||
elseif formname == "yl_speak_up:manage_variables" then
|
elseif formname == "yl_speak_up:manage_variables" then
|
||||||
yl_speak_up.input_fs_manage_variables(player, formname, fields)
|
yl_speak_up.input_fs_manage_variables(player, formname, fields)
|
||||||
return true
|
return true
|
||||||
|
-- handled in fs_alternate_text.lua
|
||||||
|
elseif formname == "yl_speak_up:show_what_points_to_this_dialog" then
|
||||||
|
yl_speak_up.input_fs_show_what_points_to_this_dialog(player, formname, fields)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -282,6 +286,10 @@ yl_speak_up.show_fs = function(player, fs_name, param)
|
|||||||
minetest.show_formspec(pname, "yl_speak_up:manage_variables",
|
minetest.show_formspec(pname, "yl_speak_up:manage_variables",
|
||||||
yl_speak_up.get_fs_manage_variables(player, param))
|
yl_speak_up.get_fs_manage_variables(player, param))
|
||||||
|
|
||||||
|
elseif(fs_name == "show_what_points_to_this_dialog") then
|
||||||
|
minetest.show_formspec(pname, "yl_speak_up:show_what_points_to_this_dialog",
|
||||||
|
yl_speak_up.show_what_points_to_this_dialog(player, param))
|
||||||
|
|
||||||
-- fallback in case of wrong call
|
-- fallback in case of wrong call
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(pname, "Error: Trying to show wrong "..
|
minetest.chat_send_player(pname, "Error: Trying to show wrong "..
|
||||||
|
Loading…
Reference in New Issue
Block a user