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.
Printable View
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.
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.
Make a function in desktop/scripts/dice_counter.lua, something like:
Then, assuming that control.diegroup is valid where you run your code, call the function with: control.diegroup.getPips()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
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:
The problem is the if loop doesn't run because the control isn't carrying into the function. the first debug generates a nil.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
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:
I think I have to define that there are 5 stages of button press, but I don't know how to do that part.Quote:
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.
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
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.