PDA

View Full Version : Help with buttongroup



Stv
June 4th, 2020, 08:57
OK time to show my ignorance again.

I have the following code in a quick test setup just to set a test database value and tie it to some buttons


function onInit()
newnode=DB.createChild("testnode","test","number")
Debug.console("newnode",newnode)
DB.setValue(newnode,"","number",2)
end

Then in my xml file I have

<buttongroup_counter name="legrescounter" source="testnode.test">
<anchored to="legres_label" position="righthigh" offset="40,0" />
<values>
<maximum>8</maximum>
<current>4</current>
</values>

</buttongroup_counter>
Which I was hoping would give me a working set of butons to play around with, which it does to a degree.
The buttons display in the combattracker where I have set them, they have the correct number of buttons, and are filled in upto number 4.

But when I 1st press the buttons, nothing happens, when they are pressed for the second time the following error is produced :

Script Error: [string "common/scripts/buttongroup_counter.lua"]:128: attempt to compare nil with number

I'm obviously doing something incorrectly, what do I need to add/change to get this to work ?

Cheers, Steve.

Stv
June 4th, 2020, 09:13
Aaaaand after many hours of staring at the same code,
It turns out I just need to set the <current> field to point to the database node.

Can't believe I tried that *just* after posting the initial question.

Cheers, Steve.

Stv
June 4th, 2020, 14:33
Turns out I'm not right...
The buttons now update when I press then, but they are not getting their initial value from my database node.
Does anyone have any insight on this please ?

Cheers, Steve.