mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-07-22 13:28:54 +02:00
added delete button for trade limit
This commit is contained in:
parent
fe3b4c80df
commit
15197a8861
@ -18,14 +18,14 @@ yl_speak_up.input_edit_trade_limit = function(player, formname, fields)
|
|||||||
|
|
||||||
local anz = tonumber(fields['SellIfMoreThan'] or "0")
|
local anz = tonumber(fields['SellIfMoreThan'] or "0")
|
||||||
if( anz and anz > 0 and anz < 10000 ) then
|
if( anz and anz > 0 and anz < 10000 ) then
|
||||||
dialog.trades.limits.sell_if_more[ fields["item_name"] ] = anz;
|
dialog.trades.limits.sell_if_more[ fields["item_name"] ] = anz
|
||||||
yl_speak_up.log_change(pname, n_id, "sell_if_more set to "..tostring(anz)..
|
yl_speak_up.log_change(pname, n_id, "sell_if_more set to "..tostring(anz)..
|
||||||
" for "..tostring(fields["item_name"]))
|
" for "..tostring(fields["item_name"]))
|
||||||
end
|
end
|
||||||
|
|
||||||
anz = tonumber(fields['BuyIfLessThan'] or "0")
|
anz = tonumber(fields['BuyIfLessThan'] or "0")
|
||||||
if( anz and anz > 0 and anz < 10000 ) then
|
if( anz and anz > 0 and anz < 10000 ) then
|
||||||
dialog.trades.limits.buy_if_less[ fields["item_name"] ] = anz;
|
dialog.trades.limits.buy_if_less[ fields["item_name"] ] = anz
|
||||||
yl_speak_up.log_change(pname, n_id, "buy_if_less set to "..tostring(anz)..
|
yl_speak_up.log_change(pname, n_id, "buy_if_less set to "..tostring(anz)..
|
||||||
" for "..tostring(fields["item_name"]))
|
" for "..tostring(fields["item_name"]))
|
||||||
end
|
end
|
||||||
@ -34,7 +34,24 @@ yl_speak_up.input_edit_trade_limit = function(player, formname, fields)
|
|||||||
yl_speak_up.show_fs(player, "trade_limit", {selected = fields.item_name})
|
yl_speak_up.show_fs(player, "trade_limit", {selected = fields.item_name})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- TODO: implement delete button
|
|
||||||
|
if(fields and fields["delete_limit"]) then
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
local n_id = yl_speak_up.speak_to[pname].n_id
|
||||||
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
|
|
||||||
|
-- make sure all necessary entries in the trades table exist
|
||||||
|
yl_speak_up.setup_trade_limits(dialog)
|
||||||
|
|
||||||
|
dialog.trades.limits.sell_if_more[ fields["item_name"] ] = nil
|
||||||
|
dialog.trades.limits.buy_if_less[ fields["item_name"] ] = nil
|
||||||
|
|
||||||
|
yl_speak_up.log_change(pname, n_id, "trade limits deleted"..
|
||||||
|
" for "..tostring(fields["item_name"]))
|
||||||
|
yl_speak_up.save_dialog(n_id, dialog)
|
||||||
|
yl_speak_up.show_fs(player, "trade_limit")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- back to the normal trade list
|
-- back to the normal trade list
|
||||||
yl_speak_up.show_fs(player, "trade_limit", {selected = fields.item_name})
|
yl_speak_up.show_fs(player, "trade_limit", {selected = fields.item_name})
|
||||||
@ -68,10 +85,10 @@ yl_speak_up.get_fs_edit_trade_limit = function(player, selected_row)
|
|||||||
'item_image[-0.25,2.5;2.0,2.0;', selected, ']',
|
'item_image[-0.25,2.5;2.0,2.0;', selected, ']',
|
||||||
'label[1.0,0.0;Set limits for buy and sell]',
|
'label[1.0,0.0;Set limits for buy and sell]',
|
||||||
'label[1.5,1.0;Description:]',
|
'label[1.5,1.0;Description:]',
|
||||||
'label[4.0,1.0;', (def.description or '?'), ']',
|
'label[4.0,1.0;', minetest.formspec_escape(def.description or '?'), ']',
|
||||||
'label[1.5,2.0;Item name:]',
|
'label[1.5,2.0;Item name:]',
|
||||||
--'label[3.5,1.0;', tostring( selected ), ']',
|
--'label[3.5,1.0;', tostring( selected ), ']',
|
||||||
'field[4.0,2.0;4,1;item_name;;', tostring( selected ), ']',
|
'field[4.0,2.0;4,1;item_name;;', minetest.formspec_escape( selected ), ']',
|
||||||
'label[1.5,3.0;In stock:]',
|
'label[1.5,3.0;In stock:]',
|
||||||
'label[4.0,3.0;', tostring( item_data[1] ), ']',
|
'label[4.0,3.0;', tostring( item_data[1] ), ']',
|
||||||
'label[1.5,4.0;Sell if more than]',
|
'label[1.5,4.0;Sell if more than]',
|
||||||
@ -80,9 +97,9 @@ yl_speak_up.get_fs_edit_trade_limit = function(player, selected_row)
|
|||||||
'label[1.5,5.0;Buy if less than]',
|
'label[1.5,5.0;Buy if less than]',
|
||||||
'field[4.0,5.0;1.2,1.0;BuyIfLessThan;;', tostring( item_data[3] ), ']',
|
'field[4.0,5.0;1.2,1.0;BuyIfLessThan;;', tostring( item_data[3] ), ']',
|
||||||
'label[5.0,5.0;will end up in stock.]',
|
'label[5.0,5.0;will end up in stock.]',
|
||||||
'button[1.5,6.0;2,1.0;store_limit;Save]',
|
'button[1.0,6.0;2,1.0;store_limit;Save]',
|
||||||
'button[4.5,6.0;2,1.0;back_to_limit_list;Back]'
|
'button[3.5,6.0;2,1.0;back_to_limit_list;Back]',
|
||||||
-- TODO: delete button
|
'button[6.0,6.0;2,1.0;delete_limit;Delete]'
|
||||||
}
|
}
|
||||||
return table.concat(formspec, '')
|
return table.concat(formspec, '')
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user