mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-07-04 04:58:03 +02:00
support for d_name in edit_actions
This commit is contained in:
parent
5f7f769d87
commit
1e2981fc38
@ -439,12 +439,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
|
||||
v[ "a_value" ] = data.trade_id
|
||||
v[ "a_pay" ] = dialog.trades[ data.trade_id ].pay
|
||||
v[ "a_buy" ] = dialog.trades[ data.trade_id ].buy
|
||||
v[ "a_on_failure" ] = ""
|
||||
if(data.action_failure_dialog) then
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
v[ "a_on_failure" ] = sorted_dialog_list[ data.action_failure_dialog ]
|
||||
end
|
||||
yl_speak_up.edit_mode_set_a_on_failure(data, pname, v)
|
||||
end
|
||||
|
||||
-- "The NPC gives something to the player (i.e. a quest item).", -- 4
|
||||
@ -470,12 +465,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
|
||||
"button[1.5,2.0;2,0.9;back_from_error_msg;Back]"})
|
||||
return
|
||||
end
|
||||
v[ "a_on_failure" ] = ""
|
||||
if(data.action_failure_dialog) then
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
v[ "a_on_failure" ] = sorted_dialog_list[ data.action_failure_dialog ]
|
||||
end
|
||||
yl_speak_up.edit_mode_set_a_on_failure(data, pname, v)
|
||||
-- change the node in the slot
|
||||
local stack = trade_inv:get_stack( trade_inv_list, 1)
|
||||
if(not(stack) or not(minetest.registered_items[ stack:get_name() ])) then
|
||||
@ -602,9 +592,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
|
||||
"button[1.5,2.0;2,0.9;back_from_error_msg;Back]"})
|
||||
return
|
||||
end
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
v[ "a_on_failure" ] = sorted_dialog_list[ data.action_failure_dialog ]
|
||||
yl_speak_up.edit_mode_set_a_on_failure(data, pname, v)
|
||||
|
||||
elseif(what_type == "deal_with_offered_item" and id_prefix == "r_") then
|
||||
if(not(data.select_deal_with_offered_item) or data.select_deal_with_offered_item < 2) then
|
||||
@ -624,8 +612,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
|
||||
or (id_prefix == "r_" and what_type == "custom")) then
|
||||
v[ id_prefix.."value" ] = data.custom_param
|
||||
if(id_prefix == "a_") then
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
v[ "a_on_failure" ] = sorted_dialog_list[ data.action_failure_dialog ]
|
||||
v[ "a_on_failure" ] = data.action_failure_dialog
|
||||
end
|
||||
|
||||
-- "the type of the entity of the NPC",
|
||||
@ -1033,9 +1020,8 @@ yl_speak_up.handle_input_fs_edit_option_related = function(player, formname, fie
|
||||
if(fields.select_on_action_failure
|
||||
and data and data.what and id_prefix == "a_") then
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
local nr = table.indexof(sorted_dialog_list, fields.select_on_action_failure)
|
||||
yl_speak_up.speak_to[pname][ tmp_data_cache ].action_failure_dialog = nr
|
||||
yl_speak_up.speak_to[pname][ tmp_data_cache ].action_failure_dialog =
|
||||
yl_speak_up.d_name_to_d_id(dialog, fields.select_on_action_failure)
|
||||
end
|
||||
|
||||
-- new variables have to be added (and deleted) somewhere after all
|
||||
@ -1303,9 +1289,7 @@ yl_speak_up.build_fs_edit_option_related = function(player, table_click_result,
|
||||
-- npc_gives/npc_wants (action)
|
||||
-- (two seperate functions, but can be handled here together)
|
||||
elseif(data.what and id_prefix == "a_" and (data.what == 4 or data.what == 5)) then
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
data.action_failure_dialog = math.max(1,
|
||||
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
||||
data.action_failure_dialog = e[ "a_on_failure" ]
|
||||
-- data.item_string is used to show a background image
|
||||
data.item_string = e[ "a_value"] -- stack name and count (as string)
|
||||
data.item_desc = e[ "a_item_desc" ]
|
||||
@ -2192,9 +2176,7 @@ yl_speak_up.get_sub_fs_edit_option_action_trade = function(
|
||||
data.pay = dialog.trades[ data.trade_id ].pay[1]
|
||||
data.buy = dialog.trades[ data.trade_id ].buy[1]
|
||||
end
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
data.action_failure_dialog = math.max(1,
|
||||
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
||||
data.action_failure_dialog = e[ "a_on_failure" ]
|
||||
end
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
local d_id = yl_speak_up.speak_to[pname].d_id
|
||||
@ -2380,9 +2362,7 @@ yl_speak_up.get_sub_fs_edit_option_action_text_input = function(
|
||||
if(e) then
|
||||
data.quest_question = e[ "a_question" ]
|
||||
data.quest_answer = e[ "a_value" ]
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
data.action_failure_dialog = math.max(1,
|
||||
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
||||
data.action_failure_dialog = e[ "a_on_failure" ]
|
||||
end
|
||||
return formspec..
|
||||
"label[0.2,3.3;What to ask the player and which answer to expect:]"..
|
||||
@ -2423,9 +2403,7 @@ yl_speak_up.get_sub_fs_edit_option_all_custom = function(
|
||||
if(e) then
|
||||
data.custom_param = e[ id_prefix.."value" ]
|
||||
if(id_prefix == "a_") then
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
data.action_failure_dialog = math.max(1,
|
||||
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
||||
data.action_failure_dialog = e[ "a_on_failure" ]
|
||||
end
|
||||
end
|
||||
formspec = formspec..
|
||||
@ -2528,14 +2506,21 @@ end
|
||||
yl_speak_up.set_on_action_failure_dialog = function(pname, data, instruction)
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
local nr = 1
|
||||
if(data and data.action_failure_dialog) then
|
||||
nr = data.action_failure_dialog + 1
|
||||
end
|
||||
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
local sorted_dialog_list = yl_speak_up.get_sorted_dialog_name_list(dialog)
|
||||
if(data and data.action_failure_dialog
|
||||
and dialog.n_dialogs
|
||||
and dialog.n_dialogs[data.action_failure_dialog]) then
|
||||
local t = dialog.n_dialogs[data.action_failure_dialog].d_name or data.action_failure_dialog
|
||||
nr = math.max(0, table.indexof(sorted_dialog_list, t)) + 1
|
||||
end
|
||||
local start_at = "9.9;"
|
||||
if(nr and nr > 1) then
|
||||
start_at = "9.7;"
|
||||
end
|
||||
local on_failure_dialog =
|
||||
"label[0.2,9.9;"..tostring(instruction).." If he doesn't, go to dialog:]"..
|
||||
"dropdown[11.0,9.6;2.7,0.6;select_on_action_failure;"..
|
||||
"label[0.2,"..start_at..tostring(instruction).." If he doesn't, go to dialog:]"..
|
||||
"dropdown[11,9.6;8.0,0.6;select_on_action_failure;"..
|
||||
"- current one -,"..
|
||||
table.concat(sorted_dialog_list, ",")..";"..tostring(nr)..";]"
|
||||
if(nr and nr > 1) then
|
||||
@ -2545,9 +2530,20 @@ yl_speak_up.set_on_action_failure_dialog = function(pname, data, instruction)
|
||||
data,
|
||||
sorted_dialog_list[ nr - 1],
|
||||
"1.2,10.2;18.0,1.8;d_text",
|
||||
"label[13.8,9.9;and show the following *modified* text:]",
|
||||
"label[0.2,10.1;...and show the following *modified* text:]",
|
||||
"",
|
||||
"button_edit_action_on_failure_text_change")
|
||||
end
|
||||
return on_failure_dialog
|
||||
end
|
||||
|
||||
|
||||
yl_speak_up.edit_mode_set_a_on_failure = function(data, pname, v)
|
||||
if(pname and data and data.action_failure_dialog) then
|
||||
v[ "a_on_failure" ] = yl_speak_up.d_name_to_d_id(
|
||||
yl_speak_up.speak_to[pname].dialog,
|
||||
data.action_failure_dialog)
|
||||
else
|
||||
v[ "a_on_failure" ] = ""
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user