menu = { options=nil, old_update=nil, selected=1, return_function=nil, show=function(op, retfun) menu.options=op menu.old_update=update update=menu.update menu.selected=1 menu.return_function=retfun end, update=function() menu.old_update() rectfill(10,20, 150, 34+#menu.options*10,6) rect(10,20, 150, 34+#menu.options*10,8) for i,v in ipairs(menu.options) do color(4) if menu.selected==i then color(15) prnt(">",20,20+i*10) end prnt(v[1],24,20+i*10) end if btnp(KEY_DOWN) then menu.selected=menu.selected+1 end if btnp(KEY_UP) then menu.selected=menu.selected-1 end if menu.selected==0 then menu.selected=#menu.options end if menu.selected>#menu.options then menu.selected=1 end if btnp(KEY_RETURN) then update=menu.old_update menu.options[menu.selected][2]() end if btnp(KEY_ESCAPE) then if menu.return_function then update=menu.old_update menu.return_function() end end end }