If someone could tell me what doesn't work, and or fix it, I'd be happy to give you credit.
API:
-- Jazzas Menu API V 0.0_1
--functionList--
--menu.setMenu(subMenuName,subMenuParent,numOfOptions,option1,function1)
--menu.setPointer(point)
--menu.menu(name)
function setPointer(point)
pointer = point
end
function printCentered(str, ypos)
term.setCursorPos(w/2 - #str/2, ypos)
print(str)
end
function clear()
term.clear()
term.setCursorPos(1,1)
end
function Menu(name)
while true do
w,y = term.getSize()
menuSelected = 1
clear()
term.setCursorPos(15,9)
write(pointer)
startline = 9 - menuSelected + 8 -#tArgs/2-1
printCentered(menuOptions[1],startline)
for c = 1,#tArgs-1, 2 do
printCentered(MenuID[name .. c],startline])
startline = startline+1
end
a,keys = os.pullEvent("key")
if keys == 200 and menuSelected > 1 then
menuSelected = menuSelected - 1
elseif keys == 208 and menuSelected < 8 then
menuSelected = menuSelected + 1
elseif keys == 28 and menuSelected == 1 then
MenuID[name .. 4]()
elseif keys == 208 and menuSelected == 2 then
MenuID[name .. 6]()
elseif keys == 208 and menuSelected == 3 then
MenuID[name .. 8]()
elseif keys == 208 and menuSelected == 4 then
MenuID[name .. 10]()
elseif keys == 208 and menuSelected == 5 then
MenuID[name .. 12]()
elseif keys == 208 and menuSelected == 6 then
MenuID[name .. 14]()
elseif keys == 208 and menuSelected == 7 then
MenuID[name .. 16]()
elseif keys == 208 and menuSelected == 8 then
MenuID[name .. 2]()
end
end
end
function setMenu(...)
tArgs = {...}
name = tArgs[1]
MenuID[name .. 1] = {tArgs[2]} --parent
MenuID[name .. 2] = {tArgs[3]} --num
MenuID[name .. 3] = {tArgs[4]}
MenuID[name .. 4] = {tArgs[5]}
MenuID[name .. 5] = {tArgs[6]}
MenuID[name .. 6] = {tArgs[7]}
MenuID[name .. 7] = {tArgs[8]}
MenuID[name .. 8] = {tArgs[9]}
MenuID[name .. 9] = {tArgs[10]}
MenuID[name .. 10] = {tArgs[11]}
MenuID[name .. 11] = {tArgs[12]}
MenuID[name .. 12] = {tArgs[13]}
MenuID[name .. 13] = {tArgs[14]}
MenuID[name .. 14] = {tArgs[15]}
MenuID[name .. 15] = {tArgs[16]}
MenuID[name .. 16] = {tArgs[17]}
table.insert(MenuID,"Back")
end
What's in the program:
menu.setMenu(main,"",6,"Hello","hello","Startup","startup","Goodbye","goodbye")
menu.setPointer("=>")
menu.menu(main)
function hello()
end
function startup()
end
function goodbye()
end
Thanks, Jazza