This is my first mod that uses any of the mod_gui functions. I've cobbled together something that mostly works, mainly from the tight_space scenario.
One thing I can't figure out though: the array I have for items to pay back has both entities and items in it. If you paste down a beacon with modules inside, I create both the beacon and the modules inside, and add all to the list. So if I use
Code: Select all
info_table.add{type="label", caption={'entity-name.' .. item_internal_name, {"colon"}}}
Code: Select all
info_table.add{type="label", caption={'item-name.' .. item_internal_name, {"colon"}}}
Code: Select all
local function addLoanWindowRow(p_name, item_internal_name, count)
if not global.players[p_name].info_table then
initLoanWindow(p_name)
end
local info_table = global.players[p_name].info_table
if global.players[p_name].loan_window_labels[item_internal_name] then
global.players[p_name].loan_window_labels[item_internal_name].caption = util.format_number(count)
else
--Table.add fills in one cell at a time.
info_table.add{type="label", caption={'entity-name.' .. item_internal_name, {"colon"}}}
--We need to set a name field and save a reference to update this row in a timely manner.
global.players[p_name].loan_window_labels[item_internal_name] = info_table.add{type="label", caption=util.format_number(count), name=item_internal_name}
end
end