-
January 23rd, 2020, 04:15 #11
Yuppers, I am definitely will be able to use that as well. Because I am also maintaining both internally. I just wanted to have an AC display that does not display either directly - just combines them into one string (original intended as a UI only control but for now giving up since haven’t see code to update a control for some reason anywhere yet)
In dB, as I listed above - 2 seperatr sub fields to defenses. In UI, a single displayed value: “8 [11]”, which for now ... I’ll deal with it being another stringFIELD instead. For now.
-
January 23rd, 2020, 04:27 #12
Of course, now the I go to my NEXT UI element I see I need to again switch from my intention of UI element to DB field.
I store attacks in DB where there may be multiple attack types and my intent was to present this to users in UI front page (vs when USING them and they list separately) summary as:
"2 Claws (1d6), 1 Bite (1d8)"
Of course, after writing this, I realize it will be a pain to ensure plural handling well... my initial writing (which I have never run since still building out) was done quickly without considering not everything is bite/claw/kick/etc (was looking at limited monsters)
Code:function onAttacksChanged() local aAttacks = DB.getChildren(nodeChar, "attacks"); local nTypesOfAttacks = #aAttacks; local sAttacks = ""; for idx,attack in ipairs(aAttacks) do local nNumberOfAttacks = DB.getValue(attack, "numberOfAttacks", 1); local bIsMoreThanOneAttack = (nNumberOfAttacks > 1); sAttacks = bIsMoreThanOneAttack and toString(nNumberOfAttacks) or "" .. DB.getValue(attack, "name") .. bIsMoreThanOneAttack and "s" or "" .. " (" .. DB.getValue(attack, "damage") .. ")"; if idx ~= nTypesOfAttacks then sAttacks = sAttacks .. ", "; end end end
Code:<attacks> <bite> <name type="string">Bite</name> <damage type="string">1d6</damage> <numberOfAttacks>1</numberOfAttacks> </bite> <claw> <name type="string">Claw</name> <damage type="string">1d8</damage> <numberOfAttacks>2</numberOfAttacks> </claw> </attacks>
As I wrote this ... I realized I COULD create a simple plural map config table where did. Plurals["Claw"] = "Claws". etc. but I digress ... will make a note of it for later...
-
January 23rd, 2020, 08:39 #13
To answer this question - see the API documentation: https://www.fantasygrounds.com/refdo...l.xcp#setValue
To access controls in the GUI hierarchy use <scope>.<control name>
Where scope is detailed here: https://www.fantasygrounds.com/wiki/...pt_Block_Scope
For example, if you wanted to access a control called acasc within the same window where the code is running use window.acasc
So, to set a number control to 10: window.acasc.setValue(10);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!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks