mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-29 10:38:03 +02:00
added input formspec for action of type trade
This commit is contained in:
parent
51e8e197b4
commit
5d0083212a
@ -652,6 +652,7 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
|||||||
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 = nr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
-- "Normal trade - one item(stack) for another item(stack).", -- 3
|
-- "Normal trade - one item(stack) for another item(stack).", -- 3
|
||||||
-- (only for actions)
|
-- (only for actions)
|
||||||
-- TODO: this needs to be adjusted
|
-- TODO: this needs to be adjusted
|
||||||
@ -664,6 +665,10 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
|||||||
yl_speak_up.show_fs(player, "add_trade_simple", tostring(d_id).." "..tostring(o_id))
|
yl_speak_up.show_fs(player, "add_trade_simple", tostring(d_id).." "..tostring(o_id))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
-- TODO: set trade_id in the input_ function and then call
|
||||||
|
-- yl_speak_up.input_add_trade_simple(player, formname, fields)
|
||||||
|
-- TODO gets saved as: dialog.trades[ trade_id ] = {pay={ps},buy={bs}, d_id = d_id, o_id = o_id}
|
||||||
|
--]]
|
||||||
|
|
||||||
-- the player wants to change/edit a precondition or effect
|
-- the player wants to change/edit a precondition or effect
|
||||||
if(not(fields.back)
|
if(not(fields.back)
|
||||||
@ -986,6 +991,34 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
" which will be replaced automaticly like in dialog texts:"..
|
" which will be replaced automaticly like in dialog texts:"..
|
||||||
"\n$NPC_NAME$, $PLAYER_NAME$ and $OWNER_NAME$.]"
|
"\n$NPC_NAME$, $PLAYER_NAME$ and $OWNER_NAME$.]"
|
||||||
|
|
||||||
|
-- "Normal trade - one item(stack) for another item(stack).", -- 3
|
||||||
|
elseif(data.what and id_prefix == "a_" and data.what == 3) then
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
|
local d_id = yl_speak_up.speak_to[pname].d_id
|
||||||
|
local o_id = yl_speak_up.speak_to[pname].o_id
|
||||||
|
if(not(data.trade_id)) then
|
||||||
|
data.trade_id = tostring(d_id).." "..tostring(o_id)
|
||||||
|
end
|
||||||
|
yl_speak_up.speak_to[pname].trade_id = data.trade_id
|
||||||
|
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||||
|
formspec = formspec..
|
||||||
|
"label[8,2.6;Your invnetory:]"..
|
||||||
|
"list[current_player;main;8,3;8,4;]"..
|
||||||
|
"label[0.2,3.1;Configure trade with "..minetest.formspec_escape(dialog.n_npc)..":]"..
|
||||||
|
"label[0.5,3.8;The customer pays:]"..
|
||||||
|
-- show the second slot of the setup inventory in the detached player's inv
|
||||||
|
"list[detached:yl_speak_up_player_"..pname..";setup;2,4.2;1,1;]"..
|
||||||
|
"image[3.5,4.2;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
|
||||||
|
"label[4.0,3.8;"..minetest.formspec_escape(dialog.n_npc or "?").." sells:]"..
|
||||||
|
-- show the second slot of said inventory
|
||||||
|
"list[detached:yl_speak_up_player_"..pname..";setup;5,4.2;1,1;1]"..
|
||||||
|
"label[0.2,5.8;The player shall trade with the NPC at least once.\n"..
|
||||||
|
"If he doesn't, go to dialog:]"..
|
||||||
|
"dropdown[4.3,6.0;2.8,0.6;select_on_action_failure;"..
|
||||||
|
"- current one -,"..
|
||||||
|
table.concat(sorted_dialog_list, ",")..";"..tostring(nr)..";]"
|
||||||
|
|
||||||
-- "The NPC gives something to the player (i.e. a quest item).", -- 4
|
-- "The NPC gives something to the player (i.e. a quest item).", -- 4
|
||||||
-- (only for actions)
|
-- (only for actions)
|
||||||
elseif(data.what and id_prefix == "a_" and data.what == 4) then
|
elseif(data.what and id_prefix == "a_" and data.what == 4) then
|
||||||
|
@ -123,6 +123,12 @@ yl_speak_up.inventory_allow_item = function(player, stack, input_to)
|
|||||||
if(not(n_id) or not(yl_speak_up.may_edit_npc(player, n_id))) then
|
if(not(n_id) or not(yl_speak_up.may_edit_npc(player, n_id))) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
-- are we editing an action of the type trade?
|
||||||
|
if( yl_speak_up.speak_to[pname][ "tmp_action" ]
|
||||||
|
and yl_speak_up.speak_to[pname][ "tmp_action" ].what == 3) then
|
||||||
|
input_to = "yl_speak_up:edit_actions"
|
||||||
|
end
|
||||||
|
|
||||||
local error_msg = nil
|
local error_msg = nil
|
||||||
if(stack:get_wear() > 0) then
|
if(stack:get_wear() > 0) then
|
||||||
error_msg = "Your NPC accepts only undammaged items.\n"..
|
error_msg = "Your NPC accepts only undammaged items.\n"..
|
||||||
|
Loading…
Reference in New Issue
Block a user