PDA

View Full Version : Weird windowlist issue



timg
October 18th, 2025, 20:45
Hi, I am trying to put together a shops extension and am seeing some weird behavior in my shopping cart system.
I have a windowlist which contains the shop inventory and then in a subwindow another one for the cart inventory. When the user clicks an "AddToCart" button I run code in a ShopManager which copies across the nodes as needed to the cartlist element to yield the following in the database:



<cartitemlist>
<id-00004>
<count type="number">1</count>
<name type="string">Acid Flask - lesser</name>
<price type="string">3 gp</price>
<shoplink type="string">MKshops.id-00001.shopitemlist.id-00001</shoplink>
<shortcut type="windowreference">
<class>item</class>
<recordname>reference.magicitems.acidflasklesser@PF2-ORC-GM Core</recordname>
</shortcut>
</id-00004>
</cartitemlist>


The cart XML wraps this and I have verified that it is bound to the node fine.



<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<windowclass name="mkshopscart_main">
<script file="campaign/scripts/mkshopscart_main.lua"/>
<sheetdata>
<!-- Placeholder for items (bottom-right) -->
<genericcontrol name="itemsbox">
<anchored>
<top offset="10"/>
<left offset="10"/>
<right offset="-10"/>
<bottom offset="-170"/>
</anchored>
<frame name="groupbox" offset="5,5,5,5"/>
</genericcontrol>
<windowlist name="cartitemlist" >
<script>
function onFilter(w)
Debug.chat("mkshopscart_main cartlist onFilter called");
if User.isHost() then
return true;
end

local node = w.getDatabaseNode();
if DB.getValue(node, "count", 0) == 0 then
Debug.chat("mkshopscart_main cartlist onFilter - filtering 0 count row");
return false;
end

return true;
end
</script>
<anchored to="itemsbox" position="insidetopleft" offset="10,10" height="150"/>
<allowcreate/>
<allowdelete/>
<empty font="list-empty" textres="cart_emptylistitems"/>
<datasource>.cartitemlist</datasource>
<class>cart_item</class>
<child/>
<child>
<backcolor>1A40301E</backcolor>
</child>
</windowlist>
<scrollbar_list>
<anchored to="cartitemlist" />
<target>cartitemlist</target>
</scrollbar_list>

<!-- other fields -->

</sheetdata>
</windowclass>
</root>


What I am seeing is that when I click to add the first item in any row to the cart it makes every row in the windowlist only display the first element (the shortcut). Adding a second item to the row (setting count to 2) fixes it and now all controls show up in each row. Removing an item (setting count to 1 again) does not cause any issues. Removing all items in a row (setting the count to 0 again) causes the display issue to re-emerge.

What could be causing this? I do not see similar problems on the shop inventory side and it is starting to drive me crazy. Hopefully someone more up to speed on the intricacies of FG coding can shed some light for me.
Thanks
T

mccartysr
October 19th, 2025, 01:47
I don't see anything that immediately jumps out as problematic in the provided snippet. I would need the rest of the code to assess what the interactions are.