-
December 3rd, 2018, 07:27 #1
Trying to find where values are actually set for ref group lists.
Okay, I've a need to do some tweaking to how values are applied. Here is an example of what works right now.
Code: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
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
Code:["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" }; },
So, what I'm hoping to add is something like this:
Code:table.insert(rList.aColumns, { sName = "damage", sType = "string", fGet="getFullDamageString" sHeading = "Damage", nWidth=150, bCentered=true });
Code:local wItem = rList.aGroupings[sGroup].list.createWindow(node);
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.Last edited by celestian; December 3rd, 2018 at 08:59.
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
December 3rd, 2018, 09:42 #2
Look at line 182 of ref/scripts/ref_groupedlist.lua
This is where the grouplist control is created using the list_refgroupedlist template. grouplist is later used to create the rList.aGroupings[sGroup] window a few lines before the code you mention. Therefore the list_refgroupedlist template is where the "list" windowlist control is defined.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
December 4th, 2018, 05:11 #3
So, I was able to find what I was looking for and learned a good bit during the process. The bad news is it was not really what I was hoping for ;(
The spot I was looking for was in ref_groupedlist_groupitem.lua. Specifically in the function setColumnInfo(aColumns, nDefaultColumnWidth) round about here local cField = createControl(sControlClass, rColumn.sName);.
createControl creates a a control using the defined xml template(something like string_refgroupedlistgroupitem_wrap). The template's name (rColumn.sName) is the name of the new control and also it's source so in this case it was item.id-00001.damage.
So, I wrote a template of my own, added fGetValue to the rColumn variable and added a check to set the sControlClass to it...
Code:table.insert(rList.aColumns, { fGetValue = "Something.function", sName = "damage", sType = "string", sHeading = "Damage", nWidth=150, bCentered=true });
The problem is I couldn't really also handoff the "Something.function" to the template. I could write a very specific flag like "bItemDamage=true" and then within the template script..script run some custom work to setValue() after doing all the node tree negotiation. I'd need to add some handlers to watch for the node.weaponsList.damageList.* changes but otherwise maybe not so bad. I'll think about it. I was hoping I could write something that would be useful to more than just this one situation (thus others).---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
December 4th, 2018, 06:27 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,607
Can you step back about five steps for me; and describe the use case and a specific example?
Cheers,
JPG
-
December 4th, 2018, 07:17 #5
Haha, sure. As I said originally, in the weeds
Currently in my ruleset my items have a multi-node weaponlist. Each weapon can have multiple damage types. For example you have a dagger which can be used hand to hand or thrown.
I wanted to be able to capture ALL of those damage values for display in the "items" quick buttons like this.
5E uses a single string to store that entire value so it's a bit easier to just tell it to use string and the name of the value is "damage" and it works. For mine its a bit more complex. My original thought was to try and setup a method to call a function like is used for the "search filters" (block posted in previous post) but that turned out to be a bust as it used a method I was hitherto unaware of (createControl()).
Once I figured out how it worked I did a bit of jiggerypokery and added a new column value "bItemDamage=true" for that specific need and within that template I used my own script to get the fields, put them in a string value that could be displayed for this situation.
It is very specific to how I have items. Mostly because I went away from string values for damage because of my requirements/needs.
I certainly try and avoid going into ref_* because it's very difficult to follow at times (it's all very generic which means it's all variables and hard to just trace looking... which is similar to the masterindex/record list stuff) tho it did turn into a pretty good learning experience---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks