-
June 29th, 2020, 17:22 #1
Access controls inside Windowlist
Hey All,
Got a bit of a brain twizzler going on.
I've got a frame inside which I had some labels, after the labels I have a windowlist inside I have some controls.
When I drag something to that windowlist, it accepts it, I know what it is and I add it to the databasenode, all good stuff.
Now what I want to do, is to show/hide a field that's inside that windowlist, using the script that's part of the windowlist.
If I want to show hide the labels, that's all good I use 'window.label_ammo_rof.setVisible(bVisible)' - that also all works perfectly.
If I use 'Debug.console(self.getName())' it returns to me 'damageactions' which again is perfect.
I have a control called 'ammorateoffire' (it's a stringcycler) but I can't hide/show it, it can't find it.
I've tried:
self.ammorateoffire.setVisible(bVisible);
ammorateoffire.setVisible(bVisible);
And neither do anything except throw an error `attempt to index field 'ammorateoffire' (a nil value)`
Any thoughts, it's driving me insane, should be simple.
Cheers,
MBMRuleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
June 29th, 2020, 19:32 #2
I'm not sure I'm completely clear on your control hierarchy, so I'm going to make some assumtions...
Each entry within a windowlist is it's own window.
You need to get a LUA table of all the windows: https://fantasygroundsunity.atlassia...ist#getWindows
Then step through each window (using for.. in ipairs .. do) and set the control in each window returned as part of the for loop.
Have a look at the toggleVisibility function in CoreRPG ct\scripts\ct.lua as an example - "v" is the window variable.Last edited by Trenloe; June 29th, 2020 at 19:34.
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!
-
June 30th, 2020, 10:23 #3
Morning Chap,
That's not it, I don't want to iterate through the windowlist.
Here's some code. This gets called when a child has been added to the windowlist, in this case a new type of Ammo has been dragged/dropped.
Code:function updateRofFields() local sTraits = window.traits.getValue():lower() --Fetches the traits from the parent window local showrateoffire = false; if string.find (sTraits, "auto", 0, true) then showrateoffire = true; end window.label_ammo_rof.setVisible(showrateoffire); -- This hides the label self.ammorateoffire.setVisible(showrateoffire); -- This errors if (showrateoffire) then if ammorateoffire.getValue() == "" then self.ammorateoffire.setStringValue("single"); end end end
I just can't seem to 'hide/show' one field on the ammo actions window.
I'll continue with this tonight, cheers,
MBMRuleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
June 30th, 2020, 10:38 #4
Without seeing the XML I’m just guessing here...
"self" is a variable usually pointing to a control - I’m guessing the windowlist control in this case. This isn’t a container for other controls, it’s a control itself. window is a variable pointing at an instance of a windowclass - which is a container for controls.
So if you want to access a control you’ll need the window instance that it’s in.
Not knowing the GUI hierarchy, nor knowing exactly where the LUA you post above is running, I can’t give specific recommendations. Some of the script scope variables may help: https://fantasygroundsunity.atlassia...pt-Block-ScopePrivate 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!
-
June 30th, 2020, 14:52 #5
Changed my way completely.
I added a DB.addHandler to fire off an event call when the traits field got updated.
This then was enough for me to know if I needed to show the Rate of Fire field or not.
Still like to know if it's possible using .dot notation to access fields but that can wait, fixed the bug I had.
Cheers,
MBMRuleset and much more content built for FGU.
Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!
-
July 7th, 2020, 11:25 #6
When I get this it's usually some stupid spelling mistake, usually I've defined ammoRateofFire and I'm trying to change ammoRateOfFire or something.
I was also really pleased when I figured out I could do window.windowlist.window to access controls on window holding the window list holding the window I just activated a control in.Last edited by Ampersandrew; July 8th, 2020 at 16:21.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks