A helpful function to create a scrolling menuitem.
function menu(i,opt,func) local indx=0 menuitem(i,"< "..opt[1].." >", function(b) if(b==112)then func(opt[indx+2]) return end indx+=b*4-6 indx%=#opt menuitem(i,"< "..opt[indx+1].." >") end ) end |
Demo:
Nitpick: callback doesn't happen if the user changes the option value using L/R and then uses the built-in "continue" menuitem to exit the pause menu rather than pressing O/X on the changed option.
The changed value persists for when the pause menu is subsequently opened again, but this is inconsistent with actual program state which would not have been modified (presumably you'd want to do something more interesting than just print.)
[Please log in to post a comment]