function state_menu() local selected = 1 local function on_btn_draw(btn) if selected == btn.data.i then btn.color = 7 end end local buttons = { make_button({x=10, y=10, w=30, text="pLAY", data={i=1}, on_click=function() set_state(states.loading) end, on_hover=function(btn) btn.color = 7 selected = 1 end, on_draw=on_btn_draw}), make_button({x=10, y=20, w=30, text="rULES", data={i=2}, on_click=function() set_state(states.rules) end, on_hover=function(btn) btn.color = 7 selected = 2 end, on_draw=on_btn_draw}) } local function _enter() -- mouse not bound to buttons poke(0x5F2D, 1) end local function _draw() cls() draw_bg_menu() for k,button in ipairs(buttons) do button:draw(selected == k) end print("pRESS ❎/X TO CONTINUE", 8, 120, 7) end return { _enter = _enter, _update = function() for button in all(buttons) do button:update() end if btnp(UP) then selected -= 1 elseif btnp(DOWN) then selected += 1 elseif btnp(BTN_X) then buttons[selected]:on_click() end selected = mid(1, selected, #buttons) end, _draw = _draw } end