mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-07-24 14:28:54 +02:00
store amount and more/less/equal etc. for precondition player_offered_item
This commit is contained in:
parent
127263813e
commit
5644ad0cb2
@ -661,6 +661,8 @@ yl_speak_up.save_element_p_or_a_or_e = function(
|
||||
and data.item_group ~= "- no, just this one item -") then
|
||||
v["p_item_group"] = data.item_group
|
||||
end
|
||||
v["p_item_stack_size"] = data.item_stack_size
|
||||
v["p_match_stack_size"] = data.match_stack_size
|
||||
local player_inv = player:get_inventory()
|
||||
if(not(player_inv:room_for_item("main", stack))) then
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
@ -902,10 +904,14 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
||||
return
|
||||
end
|
||||
|
||||
elseif(fields.select_accept_group
|
||||
elseif(fields.select_accept_group and fields.select_accept_group ~= ""
|
||||
and data and data.what and what_type == "player_offered_item" and id_prefix == "p_") then
|
||||
data.item_group = fields.select_accept_group
|
||||
|
||||
elseif(fields.select_match_stack_size and fields.select_match_stack_size ~= ""
|
||||
and data and data.what and what_type == "player_offered_item" and id_prefix == "p_") then
|
||||
data.match_stack_size = fields.select_match_stack_size:split(" ")[1]
|
||||
|
||||
-- comparison value for a variable (same for both preconditions and effects)
|
||||
elseif(fields.var_cmp_value
|
||||
and data and data.what and what_type == "state" and id_prefix ~= "a_") then
|
||||
@ -1166,6 +1172,7 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
||||
or fields.select_inv or fields.select_block
|
||||
or fields.inv_list_name
|
||||
or fields.select_accept_group
|
||||
or fields.select_match_stack_size
|
||||
or fields.select_variable or fields.select_operator
|
||||
or fields.select_on_failure
|
||||
or fields.select_on_action_failure
|
||||
@ -1341,6 +1348,8 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
||||
data.item_desc = e[ "p_item_desc" ]
|
||||
data.item_quest_id = e[ "p_item_quest_id" ]
|
||||
data.item_group = e[ "p_item_group" ]
|
||||
data.item_stack_size = e["p_item_stack_size"]
|
||||
data.match_stack_size = e["p_match_stack_size"]
|
||||
end
|
||||
|
||||
if(e[ "alternate_text"]) then
|
||||
@ -2057,20 +2066,21 @@ yl_speak_up.get_fs_edit_option_action_npc_wants_or_accepts = function(
|
||||
data.item_quest_id = data.item_quest_id or e["item_quest_id"]
|
||||
data.item_desc = data.item_desc or e["item_desc"]
|
||||
data.item_group = data.item_group or e["item_group"]
|
||||
data.item_stack_size = data.item_stack_size or e["item_stack_size"]
|
||||
data.match_stack_size = data.match_stack_size or e["match_stack_size"]
|
||||
end
|
||||
if(data and (data.item_node_name or data.item_string)) then
|
||||
node_name = tostring(data.item_node_name or data.item_string)
|
||||
bg_img = "item_image[1.15,3.65;0.7,0.7;"..node_name.."]"
|
||||
end
|
||||
wants_or_accepts = "wants"
|
||||
action_failure_info = ""
|
||||
info_text = ""
|
||||
if(id_prefix == "p_") then
|
||||
wants_or_accepts = "accepts"
|
||||
local group_list = {minetest.formspec_escape("- no, just this one item -")}
|
||||
-- get node name without amount
|
||||
local parts = node_name:split(" ")
|
||||
local nr = 1
|
||||
local count = 1
|
||||
local amount = tostring(1)
|
||||
-- prepare group_list
|
||||
if(data and parts and minetest.registered_items[ parts[1] ]) then
|
||||
for k,v in pairs(minetest.registered_items[ parts[1] ].groups) do
|
||||
@ -2080,19 +2090,37 @@ yl_speak_up.get_fs_edit_option_action_npc_wants_or_accepts = function(
|
||||
nr = count
|
||||
end
|
||||
end
|
||||
amount = tostring(parts[2])
|
||||
end
|
||||
-- use this for the group selection dialog as well
|
||||
action_failure_info = "label[1,4.8;...and also all other items of the group:]"..
|
||||
local size_list = {"any amount", "exactly "..amount,
|
||||
"less than "..amount, "more than "..amount, "other amount than "..amount}
|
||||
local match_size = 1
|
||||
for i, list_text in ipairs(size_list) do
|
||||
if(data.match_stack_size and data.match_stack_size == list_text:split(" ")[ 1 ]) then
|
||||
match_size = i
|
||||
end
|
||||
end
|
||||
if(data) then
|
||||
data.item_stack_size = amount
|
||||
end
|
||||
info_text =
|
||||
"label[1,2.6;The player offered:]"..
|
||||
"label[6.7,3.1;of:]"..
|
||||
"dropdown[2,2.8;4.5,0.6;select_match_stack_size;"..
|
||||
table.concat(size_list, ",")..";"..
|
||||
tostring(match_size or 1)..";]"..
|
||||
"label[1,4.8;...and also all other items of the group:]"..
|
||||
"dropdown[2,5.1;5.0,0.6;select_accept_group;"..
|
||||
table.concat(group_list, ",")..";"..tostring(nr)..";]"
|
||||
else
|
||||
action_failure_info = yl_speak_up.set_on_action_failure_dialog(pname, data,
|
||||
info_text =
|
||||
"label[1,3.1;"..minetest.formspec_escape(dialog.n_npc or "?").." wants:]"..
|
||||
yl_speak_up.set_on_action_failure_dialog(pname, data,
|
||||
"The player shall give the NPC this item.")
|
||||
end
|
||||
return formspec..
|
||||
"label[8,2.6;Your inventory:]"..
|
||||
"list[current_player;main;8,3;8,4;]"..
|
||||
"label[1,3.1;"..minetest.formspec_escape(dialog.n_npc or "?").." "..wants_or_accepts..":]"..
|
||||
"list[detached:yl_speak_up_player_"..pname..";npc_wants;2,3.5;1,1;]"..
|
||||
"label[3.2,4.0;"..
|
||||
minetest.formspec_escape(
|
||||
@ -2113,7 +2141,7 @@ yl_speak_up.get_fs_edit_option_action_npc_wants_or_accepts = function(
|
||||
data.item_desc
|
||||
or "- none set -").."]"..
|
||||
bg_img..
|
||||
action_failure_info..
|
||||
info_text..
|
||||
save_button
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user