celestian
December 3rd, 2018, 07:27
Okay, I've a need to do some tweaking to how values are applied. Here is an example of what works right now.
function onButtonPress()
local w = Interface.openWindow("reference_groupedlist", "reference.weapon");
local rList = {};
rList.sRecordType = "item";
rList.sTitle = Interface.getString("item_button_weapons");
rList.aColumns = {};
table.insert(rList.aColumns, { sName = "name", sType = "string", sHeading = "Name", nWidth=200, nSortOrder=1 });
table.insert(rList.aColumns, { sName = "cost", sType = "string", sHeading = "Cost", bCentered=true });
table.insert(rList.aColumns, { sName = "damage", sType = "string", sHeading = "Damage", nWidth=150, bCentered=true });
table.insert(rList.aColumns, { sName = "weight", sType = "number", sHeading = "Weight", bCentered=true });
table.insert(rList.aColumns, { sName = "properties", sType = "string", sHeading = "Prop.", nWidth=200, bCentered=true });
rList.aFilters = {};
table.insert(rList.aFilters, { sDBField = "type", vFilterValue = "Weapon" });
rList.aGroups = {};
table.insert(rList.aGroups, { sDBField = "subtype" });
rList.aGroupValueOrder = { "Simple Melee Weapons", "Simple Ranged Weapons", "Martial Weapons", "Martial Melee Weapons", "Martial Ranged Weapons" };
w.init(rList);
end
That'll create a menu popup that lists all items with the type "Weapon" with name/cost/damage/weight/properties values displayed. Works great for 5e.
The thing is I've changed how weapons are in my ruleset and I'd like to have it display properly. I have a damagelist instead of a single string.
What I'd like to do is have something like we have to the search filters. The search filters have an option to use a value returned by a function instead. With that I could then define the function and have it return a string with the all the damage nodes damage strings in one formatted string.
If you are familiar with scripts/data_library_5E.lua
["spell"] = {
bExport = true,
aDataMap = { "spell", "reference.spelldata" },
aDisplayIcon = { "button_spells", "button_spells_down" },
sRecordDisplayClass = "power",
aGMEditButtons = { "button_power_import" };
aGMListButtons = { "button_spells_arcane_player", "button_spells_school_player","button_spells_divine_player","button_spells_sphere_player" };
aPlayerListButtons = { "button_spells_school_player", "button_spells_sphere_player" };
aCustomFilters = {
["Sphere"] = { sField = "sphere", fGetValue = getSpellSphereValue },
["School"] = { sField = "school", fGetValue = getSpellSchoolValue },
["Type"] = { sField = "type", sType = "string" },
["Level"] = { sField = "level", sType = "number" };
},
The bolded bit is what I am referring to. The getSpellSphereValue() function takes the spell's "sphere" value and does some fiddling about and returns a more "sane" response.
So, what I'm hoping to add is something like this:
table.insert(rList.aColumns, { sName = "damage", sType = "string", fGet="getFullDamageString" sHeading = "Damage", nWidth=150, bCentered=true });
To that end I've been digging into the ref_* stuff trying to figure out just WHERE this value is set in the window for display. In the above examples I'm looking for something like local someValue = DB.getValue(node,sName,sType); Obviously it'll not look like that, more likely rList.something. The best I can trace it to is to possibly around here in CoreRPG ref/scripts/ref_groupedlist.lua in the function addListRecord() around
local wItem = rList.aGroupings[sGroup].list.createWindow(node);
I suspect it's being set with "list" which I am assuming is a value from and xml entry and uses some other functions in another .lua or inline script to actually grab the values and list them.
Does anyone have a clue WHERE "list" is? Meaning the one for this one (there are obviously serveral "list" entries in the xml. I've dug around the xml looking at the various entries trying to determine if this is where it is and if so where the code is where the listed entries values are set but ... after several hours of debugging and throwing all kinds of output to console I've hit a wall.
Am I even on the right track (is it set elsewhere?)
This is a very "in the weeds" sorta thing so I can understand if folks just say "huh?" and scratch their head. I do have a hacky/kludge I use right now (when the damage value is changed for any damage node a function will rescan ALL of them on that item and set "damage" on the item itself with a sane string) but... that itch gets me and I wanna try and do it a little better. Might just be easier to let it go but... hoping someone might have a thought.
function onButtonPress()
local w = Interface.openWindow("reference_groupedlist", "reference.weapon");
local rList = {};
rList.sRecordType = "item";
rList.sTitle = Interface.getString("item_button_weapons");
rList.aColumns = {};
table.insert(rList.aColumns, { sName = "name", sType = "string", sHeading = "Name", nWidth=200, nSortOrder=1 });
table.insert(rList.aColumns, { sName = "cost", sType = "string", sHeading = "Cost", bCentered=true });
table.insert(rList.aColumns, { sName = "damage", sType = "string", sHeading = "Damage", nWidth=150, bCentered=true });
table.insert(rList.aColumns, { sName = "weight", sType = "number", sHeading = "Weight", bCentered=true });
table.insert(rList.aColumns, { sName = "properties", sType = "string", sHeading = "Prop.", nWidth=200, bCentered=true });
rList.aFilters = {};
table.insert(rList.aFilters, { sDBField = "type", vFilterValue = "Weapon" });
rList.aGroups = {};
table.insert(rList.aGroups, { sDBField = "subtype" });
rList.aGroupValueOrder = { "Simple Melee Weapons", "Simple Ranged Weapons", "Martial Weapons", "Martial Melee Weapons", "Martial Ranged Weapons" };
w.init(rList);
end
That'll create a menu popup that lists all items with the type "Weapon" with name/cost/damage/weight/properties values displayed. Works great for 5e.
The thing is I've changed how weapons are in my ruleset and I'd like to have it display properly. I have a damagelist instead of a single string.
What I'd like to do is have something like we have to the search filters. The search filters have an option to use a value returned by a function instead. With that I could then define the function and have it return a string with the all the damage nodes damage strings in one formatted string.
If you are familiar with scripts/data_library_5E.lua
["spell"] = {
bExport = true,
aDataMap = { "spell", "reference.spelldata" },
aDisplayIcon = { "button_spells", "button_spells_down" },
sRecordDisplayClass = "power",
aGMEditButtons = { "button_power_import" };
aGMListButtons = { "button_spells_arcane_player", "button_spells_school_player","button_spells_divine_player","button_spells_sphere_player" };
aPlayerListButtons = { "button_spells_school_player", "button_spells_sphere_player" };
aCustomFilters = {
["Sphere"] = { sField = "sphere", fGetValue = getSpellSphereValue },
["School"] = { sField = "school", fGetValue = getSpellSchoolValue },
["Type"] = { sField = "type", sType = "string" },
["Level"] = { sField = "level", sType = "number" };
},
The bolded bit is what I am referring to. The getSpellSphereValue() function takes the spell's "sphere" value and does some fiddling about and returns a more "sane" response.
So, what I'm hoping to add is something like this:
table.insert(rList.aColumns, { sName = "damage", sType = "string", fGet="getFullDamageString" sHeading = "Damage", nWidth=150, bCentered=true });
To that end I've been digging into the ref_* stuff trying to figure out just WHERE this value is set in the window for display. In the above examples I'm looking for something like local someValue = DB.getValue(node,sName,sType); Obviously it'll not look like that, more likely rList.something. The best I can trace it to is to possibly around here in CoreRPG ref/scripts/ref_groupedlist.lua in the function addListRecord() around
local wItem = rList.aGroupings[sGroup].list.createWindow(node);
I suspect it's being set with "list" which I am assuming is a value from and xml entry and uses some other functions in another .lua or inline script to actually grab the values and list them.
Does anyone have a clue WHERE "list" is? Meaning the one for this one (there are obviously serveral "list" entries in the xml. I've dug around the xml looking at the various entries trying to determine if this is where it is and if so where the code is where the listed entries values are set but ... after several hours of debugging and throwing all kinds of output to console I've hit a wall.
Am I even on the right track (is it set elsewhere?)
This is a very "in the weeds" sorta thing so I can understand if folks just say "huh?" and scratch their head. I do have a hacky/kludge I use right now (when the damage value is changed for any damage node a function will rescan ALL of them on that item and set "damage" on the item itself with a sane string) but... that itch gets me and I wanna try and do it a little better. Might just be easier to let it go but... hoping someone might have a thought.