fixed trade list for older formspec versions
This commit is contained in:
parent
19625b6d3a
commit
7c5d28328c
@ -12,6 +12,12 @@ yl_speak_up.input_trade_list = function(player, formname, fields)
|
||||
dialog.trades = {}
|
||||
end
|
||||
|
||||
for k, v in pairs(fields) do
|
||||
-- diffrent buttons need diffrent names..
|
||||
if(k and string.sub(k, 1, 9) == "show_more") then
|
||||
fields.button_up = true
|
||||
end
|
||||
end
|
||||
-- pressing up and down buttons needs to be handled here
|
||||
if(fields.button_up) then
|
||||
yl_speak_up.speak_to[pname].option_index =
|
||||
@ -79,6 +85,27 @@ yl_speak_up.input_trade_list = function(player, formname, fields)
|
||||
end
|
||||
|
||||
|
||||
-- helper function for fs_trade_list: show a row of offers; returns h
|
||||
yl_speak_up.show_trade_offer_row = function(h, i, pname_for_old_fs, formspec, row_content)
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"does_not_matter_"..tostring(i),
|
||||
"", "", false, "", false,
|
||||
pname_for_old_fs, 6, table.concat(row_content, ''))
|
||||
-- allow players with older clients to scroll down; this extra line
|
||||
-- makes this a lot easier and does not show a broken partial next
|
||||
-- trade line
|
||||
if(pname_for_old_fs) then
|
||||
table.insert(formspec, "style_type[button;bgcolor=#a37e45]")
|
||||
local text = "Show more offers."
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"show_more_"..tostring(i),
|
||||
text, text,
|
||||
true, nil, nil, pname_for_old_fs)
|
||||
end
|
||||
return h
|
||||
end
|
||||
|
||||
|
||||
-- show a list of all trades the NPC has to offer
|
||||
-- if show_dialog_option_trades is set: show only those trades that are attached to options of dialogs;
|
||||
-- otherwise show only those trades attached to the trade list
|
||||
@ -192,19 +219,12 @@ yl_speak_up.get_fs_trade_list = function(player, show_dialog_option_trades)
|
||||
col = col + 1
|
||||
if(col >= yl_speak_up.trade_max_cols) then
|
||||
col = 0
|
||||
--row = row + 1
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"does_not_matter_"..tostring(i),
|
||||
"", "", false, "", false,
|
||||
pname, 6, table.concat(row_content, ''))
|
||||
h = yl_speak_up.show_trade_offer_row(h, i, pname_for_old_fs, formspec, row_content)
|
||||
row_content = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"does_not_matter_last",
|
||||
"", "", false, "", false,
|
||||
pname, 6, table.concat(row_content, ''))
|
||||
h = yl_speak_up.show_trade_offer_row(h, i, pname_for_old_fs, formspec, row_content)
|
||||
|
||||
-- set button background color back to golden/brownish
|
||||
table.insert(formspec, "style_type[button;bgcolor=#a37e45]")
|
||||
|
Loading…
Reference in New Issue
Block a user