Hello, I'm very new to pico-8 (and fairly inexperienced with coding in general) and I need a bit of help with some menu code. I'd like to have a menu that has two sections to it that you can move between with the left and right arrows. I'm working off of pixelcod's menu code example, here is what I have so far:
--menu system function init_menu() menu={"menu1","menu2"} menu.y=12 menu1 = {} menu1.x=25 menu1.options={"πΈπ’ππ¬","π΅π’ππ¬","π΅π’π¬π¦","π¨πͺπ·π¦","πͺπ―π·."} menu2 = {} menu2.x=88 menu2.options={"πΈπ©π’π±","π¬πͺπ΄π΄","π₯πͺπ΄π΄","π§π³π¦π΅","π΄π΅π―πΊ"} menu.amt=0 menu.sel=1 menu.swp=false for i in all(menu1.options,menu2.options) do menu.amt+=1 end end function update_menu() update_cursor() end function draw_menu() for i=1,menu.amt do oset=i*8 end if menu.swp==true then if i==menu.sel then spr(39,menu2.x,menu.y+oset,2,1) print(menu2.options[i],menu2.x,menu.y+oset+1,10) else spr(55,menu2.x,menu.y+oset,2,1) print(menu2.options[i],menu2.x,menu.y+oset+1,9) end else if i==menu.sel then spr(39,menu1.x,menu.y+oset,2,1) print(menu1.options[i],menu1.x,menu.y+oset+1,10) else spr(55,menu1.x,menu.y+oset,2,1) print(menu1.options[i],menu1.x,menu.y+oset+1,9) end end end function update_cursor() if (btnp(β¬οΈ)) menu.sel-=1 sfx(1) if (btnp(β¬οΈ)) menu.sel+=1 sfx(1) if (btnp(β¬ οΈ)) menu.swp=false sfx(1) if (btnp(β‘οΈ)) menu.swp=true sfx(1) if (btnp(β)) sfx(1) if (menu.sel>menu.amt) menu.sel=1 if (menu.sel<=0) menu.sel=menu.amt end |
With this, it has the two menus that you can swap between left and right but the menu options don't show up/come up as [NIL]. At this point, I'm sure its something simple that I'm just not understanding! I'm also willing to more or less start over if it means I get the result I need (if you've ever played it, I am making a Princess Tomato in Salad Kingdom homage and want it to look like this: ). Any help I can get will be greatly appreciated!
[Please log in to post a comment]