Thread: Buttongroup_counter
-
November 11th, 2019, 20:26 #31
In desktop/scripts/dice_counter.lua write some code (maybe call the function getPips ??) that calculates and returns the number of pips selected and then call that code.
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!
-
November 11th, 2019, 20:42 #32
- Join Date
- Dec 2015
- Location
- Boston, MA
- Posts
- 167
So, I tried, out of curiosity, changing it from a generic control to a button control.
The errors went away, but I get 0 whenever I call it. I did try what you said, but I guess I don't know how to make it so a variable will be collectible from the outside.
-
November 11th, 2019, 20:48 #33
Make a function in desktop/scripts/dice_counter.lua, something like:
Code:function getPips() local nPips = 0; -- Write code that gets the number of pips and store that in nPips. -- Then return nPips as follows: return nPips; end
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!
-
November 11th, 2019, 20:56 #34
- Join Date
- Dec 2015
- Location
- Boston, MA
- Posts
- 167
I thought I tried that and just kept getting either 0 or nil. But, as I'm typing, I am trying other things. For example. I realised that the getValue will return 0 because nowhere in my script am I calling a setValue.
So I have the beginning of a function here that I was trying:
Code:function updateSlots() if not bInit then return; end Debug.chat("control", control); checkBounds(); local m = getMaxValue(); local c = getCurrentValue(); if control then Debug.chat(control); Debug.chat(control.diegroup); control.diegroup.setValue(c); end
-
November 11th, 2019, 21:11 #35Private 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!
-
November 11th, 2019, 22:02 #36
- Join Date
- Dec 2015
- Location
- Boston, MA
- Posts
- 167
The reason that is happening semms to have been fixed by changing control to window, now it calls it up no problem.
Here's another issue. It seems like it was issue after issue piling up.
in https://www.fantasygrounds.com/refdo...l.xcp#setValue It states that:
Sets the value of the button control. If the value specified is greater than the number of button states defined, then the value is set to zero instead.
Intead, I set a global variable nValue = 0 at the top of the file. Then, at the bottom of the update slots, I set nValue = c, which is the current value for the button. and returned nValue. But, when I call for the roll and getDCValue function, which right now only says Debug.chat(nValue)
I get a returned value of 0. I feel like I am missing a super simple step.
-
November 11th, 2019, 22:32 #37
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,651
Don't use a buttoncontrol. That requires you to define all five states. Use a genericcontrol and define your own getValue. Make sure to liberally use Debug statements to make sure your variables are what they should be.
JPG
-
November 11th, 2019, 22:58 #38
- Join Date
- Dec 2015
- Location
- Boston, MA
- Posts
- 167
You are a godsend. You are all godsends. After messing with this code for, literally, 2 weeks, it's finally working. I can not thank you and Moon Wizard, and Damned enough for all the patience and tutelage you have given me. When I saw it working correctly, I almost cried.
-
November 11th, 2019, 23:00 #39Private 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