@name Console Menu
@inputs Console:wirelink X Y Click
@outputs Xx Yy Menu
@persist Menu Restart

Color = 577

if(Click) {
    Xx = round(((1 + X)/2)*31)
    Yy = 17 - round(((1 + Y)/2)*17)
    }

# First we make sure the screen has been cleared:
Console:writeCell( 2041, 1 )     
# write a value of 1 to the "clear-screen'" address
Console:writeCell( 2042, 0 )     
# Set the background color to black

Console:writeString("00000000" , 1, 0, Color, Color)
Console:writeString("0"        , 1, 1, Color, Color)
Console:writeString(" MENU "   , 2, 1, 111, Color - 111)
Console:writeString("0"        , 8, 1, Color, Color)
Console:writeString("00000000" , 1, 2, Color, Color)

Console:writeString("000000000" , 20, 0, Color, Color)
Console:writeString("0"         , 20, 1, Color, Color)
Console:writeString(" GUIDE "   , 21, 1, 111, Color - 111)
Console:writeString("0"         , 28, 1, Color, Color)
Console:writeString("000000000" , 20, 2, Color, Color)

Console:writeString("000000000" , 1, 15, Color, Color)
Console:writeString("0"         , 1, 16, Color, Color)
Console:writeString(" START "   , 2, 16, 111, Color - 111)
Console:writeString("0"         , 9, 16, Color, Color)
Console:writeString("000000000" , 1, 17, Color, Color)

Console:writeString("00000000000" , 18, 15, Color, Color)
Console:writeString("0"           , 18, 16, Color, Color)
Console:writeString(" EXPRESS "   , 19, 16, 111, Color - 111)
Console:writeString("0"           , 28, 16, Color, Color)
Console:writeString("00000000000" , 18, 17, Color, Color)
# 4 = Xpos, 5= Ypos, 999 = TextColor, 0 = Background color

if(Menu) {
    Console:writeString("0":repeat(20), 1, 3, Color, Color)
    Console:writeString("0":repeat(20), 1, 4, Color, Color)
    Console:writeString("0":repeat(20), 1, 5, Color, Color)
    Console:writeString("0":repeat(20), 1, 6, Color, Color)
    Console:writeString("0":repeat(20), 1, 7, Color, Color)
    Console:writeString("0":repeat(20), 1, 8, Color, Color)
    Console:writeString("0":repeat(20), 1, 9, Color, Color)
    Console:writeString("0":repeat(20), 1, 10, Color, Color)
    Console:writeString("0":repeat(20), 1, 11, Color, Color)
    Console:writeString("0":repeat(20), 1, 12, Color, Color)
    Console:writeString("0":repeat(20), 1, 13, Color, Color)
Console:writeString("0":repeat(18), 2, 4, Color-111, Color-111)
Console:writeString("0":repeat(18), 2, 5, Color-111, Color-111)
Console:writeString("0":repeat(18), 2, 6, Color-111, Color-111)
Console:writeString("0":repeat(18), 2, 7, Color-111, Color-111)
Console:writeString("0":repeat(18), 2, 8, Color-111, Color-111)
Console:writeString("0":repeat(18), 2, 9, Color-111, Color-111)
Console:writeString("0":repeat(18), 2, 10, Color-111, Color-111)
Console:writeString("0":repeat(18), 2, 11, Color-111, Color-111)
Console:writeString("0":repeat(18), 2, 12, Color-111, Color-111)
    Console:writeString("MENU"        , 2, 3, 999, Color-111)
    }

if(X<8&Y<2&Click&!Restart) {
    Menu = 1
    Restart++
    }
elseif(X<8&Y<2&Click&Restart) {
    Menu = 0
    Restart--
    }

Console:writeString("0", Xx, Yy, 999, 999)
