I have a functional menu system that works but I added another menu item and when that menu item is enabled I want to uncheck a different checkbox in the menu if that menu item is already checked. For example, suppose checkbox 2 is checked, if checkbox 3 is checked I want the checkmark in checkbox 2 to disappear as checkbox 3 takes effect. Checkbox 2 and checkbox 3 do similar things and only one of them can impact the game at a given time. If checkbox 3 is checked and the player checks checkbox 2, I would want the checkmark in checkbox 3 to disappear as checkbox 2 takes effect.
Here is what I have that applies to this situation:
I have been reading the section of the SDK that talks about playdate.menu.item:setValue(newValue) but I can't seem to check one checkbox and have that checkbox uncheck the checkbox that it's replacing. Any ideas would be appreciated, the actual actions of the checkbox work perfectly, I just want the checkboxes to reflect their current status accurately. In my example checkbox 2 and checkbox 3 cannot both be checked.
This isn't necessarily a direct solution to your problem regarding checkboxes (afaik there's no way to change a non-actioned item's setting real-time within that menu), but I feel like if I were presented with a situation like this I'd use
playdate.menu:addOptionsMenuItem() instead of trying to wrangle checkboxes.
With this, you could just have one menu item labeled "icon", that the user could use to cycle between three different options labeled "off", "comet", and "blinker", with the proper callbacks firing in your game depending on what it's set to when the menu's closed. Then you don't have to worry about updating any other menu items for a toggle, because one will govern all possible settings.
(For the record, I believe
playdate.menu.item:setValue() only works when the System menu's not actively open? Just a guess, but no game code can really run while it's open, so I don't believe it'd take effect inside the menu itself.)
Thanks, that's a good suggestion. I wondered if maybe what I was asking for was not possible. That is weird to me that you can't toggle checkboxes by selecting another checkbox but this is my first attempt using menus in Lua.