There maybe many menu functions around, but here is my own attempt, this generally for a 3 part text based main page menu system. But you can use your imagination or edit parts to suit you.
The function.
function menu3(st$,st2$,st3$,fnt$,mx#,my#,image$,image#,nil1#,nil2#,nil3#)
st$,st2$,st3$
The three strings, this is the text content of the meny, eq, "Play"."Load","Quit"
fnt$
This is the font to be used, eg. "Arial"
mx#,my#
x and y positions of where the menu will be placed.
image$,image#
Image filename and image number, eg. "back.jpg",1
nil1#,nil2#,nil3#
The number from the 'nil' function to execute, the nil function allows you to place and apply numbers to commands you want to execute on the menu.
The function snippet;
function menu3(st$,st2$,st3$,fnt$,mx#,my#,image$,image#,nil1#,nil2#,nil3#)
`Generally 'loopy' stuff
cls
sync on
sync rate 10
`This is the command for loading your image, if you don't want it, removed the image variables where you see them and
`the line below.
load image image$,image#
`The command that sets the font
set text font fnt$
`This is the original render of text
text mx#,my#,st$
text mx#,my#+30,st2$
text mx#,my#+60,st3$
`This variable is for storing a number so the function can call differant
`processes depending on the number
me# = 0
`Begin loop
do
`Show the background image
paste image image#,0,0
`If the value me# is at '0' then it will set the foreground/background colours as so, in other words
`Change the colours of your texts.
if me# = 0
ink rgb(255,255,255), rgb(0,0,0)
text mx#,my#,st$
ink rgb(100,100,100), rgb(0,0,0)
text mx#,my#+30,st2$
ink rgb(100,100,100), rgb(0,0,0)
text mx#,my#+60,st3$
endif
`Same again, if the value is 1
if me# = 1
ink rgb(100,100,100), rgb(0,0,0)
text mx#,my#,st$
ink rgb(255,255,255), rgb(0,0,0)
text mx#,my#+30,st2$
ink rgb(100,100,100), rgb(0,0,0)
text mx#,my#+60,st3$
endif
`And the same for 2
if me# = 2
ink rgb(100,100,100), rgb(0,0,0)
text mx#,my#,st$
ink rgb(100,100,100), rgb(0,0,0)
text mx#,my#+30,st2$
ink rgb(255,255,255), rgb(0,0,0)
text mx#,my#+60,st3$
endif
`Using the arrow keys to increase and decrease the me# value, with the above bit, that means
`the text colour changes on the arrow key control
if upkey()=1 then dec me#,1
if downkey()=1 then inc me#,1
`To loop the values back round if they go under or above the restricted range
if me# > 2 then me# = 0
if me# < 0 then me# = 2
`giving commands if returnkey is pressed on any of the 3 me# values
if me# = 0 and returnkey() = 1 then nil(nil1#)
if me# = 1 and returnkey() = 1 then nil(nil2#)
if me# = 2 and returnkey() = 1 then nil(nil3#)
sync
loop
endfunction
You will also need the the 'nil' function afterwards
function nil(nil#)
REM Insert numbered commands to execute.
endfunction
If I were using in the menu function, 1,2,3 in the nil, look at what the nil function would be;
function nil(nil#)
if nil# = 1 then text 0,10,"GAME!"
if nil# = 2 then testing()
if nil# = 3 then end
endfunction
Here is an example in action if you will.
set text size 28
menu3("New Game","Options","Quit","Arial",450,350,"Control/Data/GUI/Images/title.jpg",1,1,2,3)
REM MENU3 FUNCTION HERE
function nil(nil#)
if nil# = 1 then text 0,10,"GAME!"
if nil# = 2 then text 0,10,"OPTION!"
if nil# = 3 then end
endfunction