addOptionsMenuItem is not looping trough options

,

Hello,

I'm having trouble using "addOptionsMenuItem".
I was thinking the function would execute everytime you cycle trough the options, but it only execute once no matter how much you cycle.
I wrote this little function to cycle trough 3 languages options in game, but it only +1 once and not multiple time when you cycle.

menu:addOptionsMenuItem("Language", locISO, locID, function()
	locID = locID + 1
	if locID > locIDMax then
		locID = 1
	end
end)

locISO is : locISO = {"EN", "FR", "DE"}
locIDMax is : locIDMax = #locISO

Anything I did or understood wrong ?

User code can't run while the system menu's open. For this feature specifically, the function only gets called once; when the system menu's closed (just before playdate.gameWillResume(). The function also only fires if the option has been actively changed while the system menu's open. If it hasn't been touched, the function won't be run when the menu is closed.)
The callback gets passed a string matching the highlighted option at time of closing, which you can use to determine the option the user selected.

src: Inside Playdate

1 Like

Ha, I wasn't aware of the callBack value, my bad.
Thanks for the info ! <3

1 Like