diff --git a/editor/edit_mode.lua b/editor/edit_mode.lua index 6b95366..c26179c 100644 --- a/editor/edit_mode.lua +++ b/editor/edit_mode.lua @@ -148,6 +148,7 @@ yl_speak_up.add_to_command_help_text = yl_speak_up.add_to_command_help_text.. -- -- trade one item(stack) against one other item(stack) -- dofile(modpath .. "api/api_trade_inv.lua") dofile(modpath .. "trade_in_edit_mode.lua") + dofile(modpath .. "fs/fs_add_trade_simple_in_edit_mode.lua") -- dofile(modpath .. "fs/fs_do_trade_simple.lua") -- handle back button diffrently when editing a trade as an action: dofile(modpath .. "fs/fs_do_trade_simple_in_edit_mode.lua") diff --git a/editor/fs/fs_add_trade_simple_in_edit_mode.lua b/editor/fs/fs_add_trade_simple_in_edit_mode.lua new file mode 100644 index 0000000..1e22d0d --- /dev/null +++ b/editor/fs/fs_add_trade_simple_in_edit_mode.lua @@ -0,0 +1,31 @@ +-- override fs/fs_add_trade_simple.lua: +-- (this is kept here as it is trade related and does not change the formspec as such) + +local old_input_add_trade_simple = yl_speak_up.input_add_trade_simple +yl_speak_up.input_add_trade_simple = function(player, formname, fields, input_to) + if(not(player)) then + return 0 + end + local pname = player:get_player_name() + + input_to = "add_trade_simple" + -- 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 + and yl_speak_up.in_edit_mode(pname) + and yl_speak_up.edit_mode[pname] == n_id) then + input_to = "edit_actions" + end + + return old_input_add_trade_simple(player, formname, fields, input_to) +end + + +yl_speak_up.register_fs("add_trade_simple", + -- the input function is a new one now + yl_speak_up.input_add_trade_simple, + -- the get_fs function stays the same + yl_speak_up.get_fs_add_trade_simple_wrapper, + -- force formspec version 1 (not changed): + 1 +) diff --git a/editor/trade_in_edit_mode.lua b/editor/trade_in_edit_mode.lua index 21aaddd..35d5a6f 100644 --- a/editor/trade_in_edit_mode.lua +++ b/editor/trade_in_edit_mode.lua @@ -68,36 +68,3 @@ yl_speak_up.delete_trade_simple = function(player, trade_id) end return old_delete_trade_simple(player, trade_id) end - - --- override fs/fs_add_trade_simple.lua: --- (this is kept here as it is trade related and does not change the formspec as such) - -local old_input_add_trade_simple = yl_speak_up.input_add_trade_simple -yl_speak_up.input_add_trade_simple = function(player, formname, fields, input_to) - if(not(player)) then - return 0 - end - local pname = player:get_player_name() - - input_to = "add_trade_simple" - -- 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 - and yl_speak_up.in_edit_mode(pname) - and yl_speak_up.edit_mode[pname] == n_id) then - input_to = "edit_actions" - end - - return old_input_add_trade_simple(player, formname, fields, input_to) -end - - -yl_speak_up.register_fs("add_trade_simple", - -- the input function is a new one now - yl_speak_up.input_add_trade_simple, - -- the get_fs function stays the same - yl_speak_up.get_fs_add_trade_simple_wrapper, - -- force formspec version 1 (not changed): - 1 -)