Hi,
I want to make a mute button that is updated via JSON, so if the player has chosen to mute the game, the next time he enters the game, it will remember if the game is muted or not.
problem is-
I don’t really know how to set the InitialSwitchState on my On/Off button …
I tried doing that with a function but It didnt work-
local function checkboxSwitchListener( event )
– Update the status box text
if(event.target.isOn) then
Data.Sound=1;
else
Data.Sound=0;
end
local stringified=json.encode(Data)
file= io.open(path,“w”)
file:write(stringified)
io.close(file)
print(Data.Sound);
end
– Create a default checkbox button (using widget.setTheme)
local onOffSwitch = widget.newSwitch
{
left = 10,
top = 80,
id = “My on/off switch widget”,
--initialSwitchState = checkInitial,
onPress = checkboxSwitchListener,
onRelease= checkboxSwitchListener,
}
local function checkInitial()
if(Data.Sound==1) then
return true;
else
return false;
end
end
what am I doing wrong here?