Im trying to draw a checkbox right but i want to make it a function
function drawCheckBox(x, y, distance, title, variable)
local mousePos = input:get_mouse_pos()
local checkBoxColor
local checkSize = 15;
if (mousePos.x > x and mousePos.x < x + checkSize) and (mousePos.y > y and mousePos.y < y + checkSize) then
if input:is_key_down( 0x1 ) then
variable = not variable
end
end
if variable == true then
checkBoxColor = colors.white
else
checkBoxColor = colors.red
end
render:rect_filled( x, y, checkSize, checkSize, checkBoxColor)
render:text( font, x + distance, y, title, colors.white )
end
to call it I have a global variable as "variable" in the function so that I can reference the bool of the checkbox
drawCheckBox(100, 100, 50, 'Test One', checkboxVars.testOne)
but the issue is when i press on the checkbox it doesn't change the global