Hi there,
I need to create several check boxes and label them according to a number and data from a table.
I think I can do it using a for, but I’haven’t been able to do it.
Can anyone point me in the right direction?
Cheers,
Hi there,
I need to create several check boxes and label them according to a number and data from a table.
I think I can do it using a for, but I’haven’t been able to do it.
Can anyone point me in the right direction?
Cheers,
I don’t understand the issue. What specially are you having trouble doing?
local widget = require( "widget" ) local function onSwitchPress( event ) local switch = event.target print( "Switch with ID '"..switch.id.."' is on: "..tostring(switch.isOn) ) end local params = { left = 250, top = 200, style = "checkbox", onPress = onSwitchPress } for i = 1, 5 do params.left = 250 + (i-1) \* 40 params.id = "Checkbox" .. i local checkboxButton = widget.newSwitch( params ) end
That is the essential structure. Modify it and add additional parameters fields as needed, either creating them at the time (in the loop) or by pulling them from a pre-defined table.
Thanks a lot Roaminggamer!
I was struggling with the for part. I’m a linguist learning to code haha. The structure you provided thought me a lot. I just modified it according to my needs.
Thanks!
I don’t understand the issue. What specially are you having trouble doing?
local widget = require( "widget" ) local function onSwitchPress( event ) local switch = event.target print( "Switch with ID '"..switch.id.."' is on: "..tostring(switch.isOn) ) end local params = { left = 250, top = 200, style = "checkbox", onPress = onSwitchPress } for i = 1, 5 do params.left = 250 + (i-1) \* 40 params.id = "Checkbox" .. i local checkboxButton = widget.newSwitch( params ) end
That is the essential structure. Modify it and add additional parameters fields as needed, either creating them at the time (in the loop) or by pulling them from a pre-defined table.
Thanks a lot Roaminggamer!
I was struggling with the for part. I’m a linguist learning to code haha. The structure you provided thought me a lot. I just modified it according to my needs.
Thanks!