-
April 12th, 2018, 00:13 #1
Which control/object defines ‘source=“...”’ attribute?
Was going through the API page control by control looking for this. Basically, once found was going to see if there was any API call in lua to set/reset this db value. I. was thinking that I had 5 controls that depending on a config switch would represent one of two sets of 5 values.
Didn’t want to use a vague path like .save1, save2, etc.
Am I, as usual, myopic and missed the entry?
-
April 12th, 2018, 04:29 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,412
In those cases, it's best to use two controls and show/hide the correct controls based on which config is active. You can't change the source of a control on the fly. For example, that's how extra fields in items are handled in the D&D rulesets.
Another option is to dynamically create/destroy controls, but then you have to track them and lay them out dynamically as well.
Technically, both subwindow and windowlist support source setting, but they are containers not raw data values.
Regards,
JPG
-
April 12th, 2018, 14:04 #3
Yup, controlling on page display was my initial thought, just the other approach followed in my head since I didn’t need to change any physicality, just the db source.
Will go the invis/vis route.
Still, I couldn’t find the control in the number/string inheritance chain with the db source tag. Did I miss it or is it left out?
PS: M-O-O-N spells Wizard of FG, thanks for the help.
-
April 12th, 2018, 19:29 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,412
Still, I couldn’t find the control in the number/string inheritance chain with the db source tag. Did I miss it or is it left out?
Some comments that may help.
If a control has a name, it can be referenced from the window script scope by name.
If a control does not have a name and is dynamically created (createControl), then you can store a reference to the control object to reference later.
If a control does not have a name and is statically created (XML), then you can't access.
If you really are just trying to update underlying data in the database, use the DB package API instead.
Regards,
JPG
-
April 12th, 2018, 22:17 #5
I'm sorry JPG, I meant something like this:
Code:<!-- AC --> <number name="armorclass" source="defenses.ac.total"> <frame name="charsheet_attribute_bonus_frame" offset="7,5,7,5"/>
So the above would be number->numberfield->numbercontrol/databasecontrol ->etc
In none of them did I see any description of a tag or attribute "source". I mean, I know what it is, it creates/references that spot in the xml/db. I had ORIGINALLY asked o then see if there was a "change source" api for it. I get what to do now.
I just wanted to still know where that attribute or tag was described. If only to understand why I didn't find it in case there was another set of data/pages/docs to look at.
I hope you are grokking in fullness now?
Thanks for your patience - I no longer "needed" the info, just want to still know where, in case.
-
April 12th, 2018, 23:10 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,412
It's only mentioned in passing here in the descriptive text.
https://www.fantasygrounds.com/refdoc/windowcontrol.xcp
It looks like it has never been fully defined in any documentation that I can find quickly. I guess it's always been used by example.
Regards,
JPG
-
April 12th, 2018, 23:54 #7
In every possible case where you are using data - access it from the database so you dont need to worry about consistenly using the right path for accessing via the window.
Access via the DB always.
Always give your control a unique name.
Keep the db syntax consistent between npc and pc.
-
April 13th, 2018, 02:26 #8
Thanks JPG - it's COOL if it WASN'T mentioned, I just hate looking at not seeing it like I have already done on prior questions. And of course sometimes it is not to be found like anchor=center which you blessed me with!
I had no problem understanding how <tag source="..."> was used - it WAS indeed self-documenting. I asked, as I said before, because I figured whatever component first introduces it would also have (if ANY had it) the method for modifying/reading it if one existed.
I'm only at the UI stage now, though SO close to starting on coding first page at least. Just trying to decide how will setup Saves and Movement controls. Then will see about shrinking the "Ability Modifiers" section - I did it initially like their Character Sheet but it looks too wide for such a limited use datapoint. But it's there and layed out so will wait until complete then revamp look.
Could you maybe show a control or two with the alternate ways of accessing the data? I am not sure what you mean by the "access it from the database so you dont need to worry about consistenly using the right path for accessing via the window." since I haven't yet coded to it.
You need not post actual controls if that would be too much to use as example. You could point to examples of alternate access methods by pointing to the free rulesets, CoreRPG or Savage Worlds or Castles & Crusades or something I can download to look at. Just mention the controls or methods to look at.
-
April 13th, 2018, 02:34 #9
random code cut from MoreCore
Code:<script> function onDoubleClick(x, y) if getValue() > 0 then local rActor = ActorManager.getActor("pc", window.getDatabaseNode()); Debug.console("rActor: "); Debug.console(rActor); local nodeWin = window.getDatabaseNode(); Debug.console("nodeWin: "); Debug.console(nodeWin); local sHeroType = nodeWin.getChild("spell_slot_1_name").getValue(); Debug.console("sHeroType: "); Debug.console(sHeroType); local msg = {font = "msgfont", icon = "spellicon"}; msg.text = rActor.sName .. " is using a " .. sHeroType; Comm.deliverChatMessage(msg); setValue(getValue()-1); end return true; end </script>
-
April 13th, 2018, 02:40 #10
Some info on the database with relation to controls here: https://www.fantasygrounds.com/wiki/...ce_Interaction
DB API here: https://www.fantasygrounds.com/refdoc/DB.xcp
And Database Node here: https://www.fantasygrounds.com/refdoc/databasenode.xcpPrivate 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