forked from your-land-mirror/yl_speak_up
options can now be marked as Done when having been visited once
This commit is contained in:
parent
189165dd22
commit
a8b92a754f
@ -386,6 +386,27 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
|||||||
d_option.o_text_when_prerequisites_not_met = fields.option_text_not_met
|
d_option.o_text_when_prerequisites_not_met = fields.option_text_not_met
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- toggle visit often/only *once*
|
||||||
|
if(d_option and fields.option_visits and fields.option_visits ~= "") then
|
||||||
|
local old_visit_mode = "often"
|
||||||
|
if(d_option.o_visit_only_once and d_option.o_visit_only_once == 1) then
|
||||||
|
old_visit_mode = "*once*"
|
||||||
|
end
|
||||||
|
if(fields.option_visits ~= old_visit_mode) then
|
||||||
|
if(fields.option_visits == "often") then
|
||||||
|
d_option.o_visit_only_once = 0
|
||||||
|
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||||
|
"Dialog "..d_id..": Option "..tostring(o_id)..
|
||||||
|
" can now be visited often/unlimited (default).")
|
||||||
|
elseif(fields.option_visits == "*once*") then
|
||||||
|
d_option.o_visit_only_once = 1
|
||||||
|
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||||
|
"Dialog "..d_id..": Option "..tostring(o_id)..
|
||||||
|
" can now be visited only *once* per talk.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- toggle autoselection/autoclick of an option
|
-- toggle autoselection/autoclick of an option
|
||||||
if(d_option and fields.option_autoanswer and fields.option_autoanswer ~= "") then
|
if(d_option and fields.option_autoanswer and fields.option_autoanswer ~= "") then
|
||||||
local old_answer_mode = "by clicking on it"
|
local old_answer_mode = "by clicking on it"
|
||||||
@ -394,7 +415,7 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
|||||||
elseif(d_option.o_autoanswer and d_option.o_autoanswer == 1) then
|
elseif(d_option.o_autoanswer and d_option.o_autoanswer == 1) then
|
||||||
old_answer_mode = "automaticly"
|
old_answer_mode = "automaticly"
|
||||||
end
|
end
|
||||||
if(fields.otpion_autoanswer ~= old_answer_mode) then
|
if(fields.option_autoanswer ~= old_answer_mode) then
|
||||||
local new_answer_mode = ""
|
local new_answer_mode = ""
|
||||||
if(fields.option_autoanswer == "by clicking on it") then
|
if(fields.option_autoanswer == "by clicking on it") then
|
||||||
d_option.o_autoanswer = nil
|
d_option.o_autoanswer = nil
|
||||||
|
@ -271,11 +271,25 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id, calle
|
|||||||
answer_mode = 2
|
answer_mode = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- show an option only once
|
||||||
|
local visit_only_once = 0
|
||||||
|
if(d_option.o_visit_only_once and d_option.o_visit_only_once == 1) then
|
||||||
|
visit_only_once = 1
|
||||||
|
end
|
||||||
|
|
||||||
local answer_text =
|
local answer_text =
|
||||||
-- answer of the player (the actual option)
|
-- answer of the player (the actual option)
|
||||||
"container[0.0,8.3]"..
|
"container[0.0,8.3]"..
|
||||||
"label[0.2,0.0;..the player may answer with this text"..
|
"label[0.2,0.0;..the player may answer with this text"..
|
||||||
minetest.formspec_escape(" [dialog option \""..tostring(o_id).."\"]:").."]"..
|
minetest.formspec_escape(" [dialog option \""..tostring(o_id).."\"]:").."]"..
|
||||||
|
"dropdown[13.3,-0.4;2.5,0.7;option_visits;"..
|
||||||
|
"often,*once*;"..tostring(visit_only_once + 1)..";]"..
|
||||||
|
"tooltip[option_visits;\"often\" allows to select this option whenever the\n"..
|
||||||
|
"\tpreconditions are fulfilled.\n"..
|
||||||
|
"\"*once*\" greys out the option after it has been selected\n"..
|
||||||
|
"\tone time successfully.\n"..
|
||||||
|
"Useful for visually marking options as read for the player.\n"..
|
||||||
|
"Talking to the NPC anew resets this option and it can be selected again.]"..
|
||||||
"dropdown[16.0,-0.4;5.3,0.7;option_autoanswer;"..
|
"dropdown[16.0,-0.4;5.3,0.7;option_autoanswer;"..
|
||||||
"by clicking on it,automaticly,randomly;"..tostring(answer_mode+1)..";]"
|
"by clicking on it,automaticly,randomly;"..tostring(answer_mode+1)..";]"
|
||||||
-- (automaticly *by fulfilling the prerequirements*)
|
-- (automaticly *by fulfilling the prerequirements*)
|
||||||
|
@ -451,11 +451,18 @@ yl_speak_up.get_fs_talkdialog_line = function(
|
|||||||
end
|
end
|
||||||
-- add a button "-> d_<nr>" that leads to the target dialog (if one is set)
|
-- add a button "-> d_<nr>" that leads to the target dialog (if one is set)
|
||||||
-- selecting an option this way MUST NOT execute the pre(C)onditions or (Ef)fects!
|
-- selecting an option this way MUST NOT execute the pre(C)onditions or (Ef)fects!
|
||||||
|
local arrow = "->"
|
||||||
|
local only_once = ""
|
||||||
|
if(sb_v.o_visit_only_once and sb_v.o_visit_only_once == 1) then
|
||||||
|
arrow = "*"
|
||||||
|
only_once = "\nNote: This option can be selected only *once* per talk!"
|
||||||
|
end
|
||||||
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
|
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
|
||||||
"button", tostring(9.6+offset)..","..h..";1,0.9", "button_" .. oid,
|
"button", tostring(9.6+offset)..","..h..";1,0.9", "button_" .. oid,
|
||||||
"->",
|
arrow,
|
||||||
"Go to target dialog "..minetest.formspec_escape(target_dialog or "")..
|
"Go to target dialog "..minetest.formspec_escape(target_dialog or "")..
|
||||||
" that will be shown when this option ("..oid..") is selected.",
|
" that will be shown when this option ("..oid..") is selected."..
|
||||||
|
only_once,
|
||||||
(target_dialog))
|
(target_dialog))
|
||||||
|
|
||||||
-- allow to set a new target dialog
|
-- allow to set a new target dialog
|
||||||
|
@ -224,7 +224,13 @@ yl_speak_up.get_fs_talkdialog_line = function(
|
|||||||
sb_v.o_text_when_prerequisites_not_met, dialog, pname))
|
sb_v.o_text_when_prerequisites_not_met, dialog, pname))
|
||||||
end
|
end
|
||||||
if(t or t_alt) then
|
if(t or t_alt) then
|
||||||
-- if(t) then t = "Visits: "..tostring(sb_v.visits or 0).." "..tostring(t) end
|
-- some options can be visited only once; talking to the NPC anew resets that
|
||||||
|
-- (not stored persistently)
|
||||||
|
if(t and sb_v.visits and sb_v.visits > 0
|
||||||
|
and sb_v.o_visit_only_once and sb_v.o_visit_only_once == 1) then
|
||||||
|
t_alt = minetest.formspec_escape("[Done] ")..t
|
||||||
|
t = nil
|
||||||
|
end
|
||||||
-- actually show the button
|
-- actually show the button
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
"button_" .. oid,
|
"button_" .. oid,
|
||||||
|
Loading…
Reference in New Issue
Block a user