Hello everybody. There is a way to force a reload of objects in a window. I'll explain,
I would like the Item window to perform reload the Items list at a certain time.
Printable View
Hello everybody. There is a way to force a reload of objects in a window. I'll explain,
I would like the Item window to perform reload the Items list at a certain time.
In general, it is possible to force windows to reload.
Yep, but how?
Well that depends on what you want to trigger the reload
Ok, it is the case that I explain better and tell you what I did and what I want to achieve.
So in my data_library I have defined more management classes for the Items and I have defined a function that associates the right class to the itemtype field of each object.
To try it out, I manually created a couple of Items in the campaign DB. The Item window shows them well and when I try to open them everything works fine. The problem is that I created them by hand, so I need a system that allows me to create the Item I want. The idea that came to my mind was to create a default class for Items. This class is used to open objects that do not have the itemtype field set. This class contains a field named itemtype (associated with a combobox) that allows me to select the item type of the object.
It almost works well. When I create a new item I can choose the item name and I can select the itemtype. On the campaign DB everything is written well.
The problem is that the generic Item window has already associated a class to the Item and does not recognize this variation until I restart the session. If I try to open the Item without restarting it always opens it with the default class.
A little bit of code:Code:["item"] = {
bExport = true,
bID = true,
aDataMap = { "itemdescription", "reference.itemdata.itemdrescription" },
aRecordDisplayClasses = {"reference_item_weapon", "reference_item_armor", "reference_item_choice"},
fRecordDisplayClass = getItemRecordDisplayClass,
-- sRecordDisplayClass = "item",
},
function getItemRecordDisplayClass(vNode)
local sRecordDisplayClass = "reference_item_choice";
if vNode ~= nil and vNode.getChild("itemtype") then
local itemType = vNode.getChild("itemtype").getValue()
if itemType == "Weapon" then
sRecordDisplayClass = "reference_item_weapon";
elseif itemType == "Armor" then
sRecordDisplayClass = "reference_item_armor";
end
end
return sRecordDisplayClass;
end
All of the D&D rulesets have a Type field that changes the fields available in the item record window based on the value of the Type field. I would look at any of the D&D rulesets for that (5E, 3.5E, etc.)
Regards,
JPG
Yep, I see. It uses subwindows.
Great hint, ty!