forked from Sokomine/yl_speak_up
took care of delete_trade_simple regarding edit_mode
This commit is contained in:
parent
e7369f3075
commit
1659aed8ab
@ -165,19 +165,8 @@ yl_speak_up.delete_trade_simple = function(player, trade_id)
|
|||||||
if(dialog and dialog.trades and trade_id
|
if(dialog and dialog.trades and trade_id
|
||||||
and dialog.trades[ trade_id ] and n_id) then
|
and dialog.trades[ trade_id ] and n_id) then
|
||||||
|
|
||||||
if( dialog.trades[ trade_id ].d_id
|
-- Note: That the trade cannot be deleted outside edit mode if it is the action
|
||||||
and yl_speak_up.edit_mode[pname] ~= n_id) then
|
-- belonging to an option is checked in editor/trade_*.lua
|
||||||
yl_speak_up.show_fs(player, "msg", {
|
|
||||||
input_to = "yl_speak_up:do_trade_simple",
|
|
||||||
formspec = "size[6,2]"..
|
|
||||||
"label[0.2,-0.2;"..
|
|
||||||
"Trades that are attached to dialog options\n"..
|
|
||||||
"can only be deleted in edit mode. Please tell\n"..
|
|
||||||
"your NPC that you are its owner and have\n"..
|
|
||||||
"new commands!]"..
|
|
||||||
"button[2,1.5;1,0.9;back_from_error_msg;Back]"})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if( dialog.trades[ trade_id ].d_id ) then
|
if( dialog.trades[ trade_id ].d_id ) then
|
||||||
back_to_d_id = dialog.trades[ trade_id ].d_id
|
back_to_d_id = dialog.trades[ trade_id ].d_id
|
||||||
back_to_o_id = dialog.trades[ trade_id ].o_id
|
back_to_o_id = dialog.trades[ trade_id ].o_id
|
||||||
|
@ -37,3 +37,34 @@ yl_speak_up.do_trade_simple = function(player, count)
|
|||||||
end
|
end
|
||||||
return old_do_trade_simple(player, count)
|
return old_do_trade_simple(player, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- overrides for api/api_trade.lua:
|
||||||
|
|
||||||
|
-- do not allow deleting trades that are actions of an option if not in edit mode:
|
||||||
|
local old_delete_trade_simple = yl_speak_up.delete_trade_simple
|
||||||
|
yl_speak_up.delete_trade_simple = function(player, trade_id)
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
local n_id = yl_speak_up.speak_to[pname].n_id
|
||||||
|
-- get the necessary dialog data
|
||||||
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
|
if(dialog and dialog.trades and trade_id
|
||||||
|
and dialog.trades[ trade_id ] and n_id) then
|
||||||
|
|
||||||
|
if( dialog.trades[ trade_id ].d_id
|
||||||
|
and yl_speak_up.edit_mode[pname] ~= n_id) then
|
||||||
|
yl_speak_up.show_fs(player, "msg", {
|
||||||
|
input_to = "yl_speak_up:do_trade_simple",
|
||||||
|
formspec = "size[6,2]"..
|
||||||
|
"label[0.2,-0.2;"..
|
||||||
|
"Trades that are attached to dialog options\n"..
|
||||||
|
"can only be deleted in edit mode. Please tell\n"..
|
||||||
|
"your NPC that you are its owner and have\n"..
|
||||||
|
"new commands!]"..
|
||||||
|
"button[2,1.5;1,0.9;back_from_error_msg;Back]"})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return old_delete_trade_simple(player, trade_id)
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user