Posted 01 September 2012 - 09:49 AM
Hey all, KaoS here. I have developed a new menu generating api for those who grow tired of writing a new function every time they need a menu, you simply construct a table in the correct format of the choices and results and pass it to the generator with your preferences, there is a syntax comment and example of use in the pastebin, give it a try
http://pastebin.com/X9cC2MS3
FEATURES:
- automatic generation in a nested area of the screen
- scrolling if all choices do not fit
- able to call any function as a result of a choice (including shell api because I did not use loadstring)
- customised delimiters to show which choice is currently selected
- the generate function returns the output of the function called
REQUESTED FEATURES
- default full screen menu if co-ordinates are omitted
- catch choices longer than separator and lengthen separator to fix
If you would like me to add anything post here or preferably PM me
Pics
First Generated:
Scrolled Right:
Scrolled Down:
Pressed enter to select (code set to simply print choice number)
Please note that I edited the menu API to update the clearing function and stop the syntax display causing an issue
http://pastebin.com/X9cC2MS3
FEATURES:
- automatic generation in a nested area of the screen
- scrolling if all choices do not fit
- able to call any function as a result of a choice (including shell api because I did not use loadstring)
- customised delimiters to show which choice is currently selected
- the generate function returns the output of the function called
REQUESTED FEATURES
- default full screen menu if co-ordinates are omitted
- catch choices longer than separator and lengthen separator to fix
If you would like me to add anything post here or preferably PM me
Pics
Spoiler
The code used:Spoiler
--[DIMENSIONS]
local x1=1
local x2=30
local y1=1
local y2=4
--[GENERATE BORDER]
for y=y1,y2 do
if y==y1 or y==y2 then
term.setCursorPos(x1,y)
write('+')
for x=x1+1,x2-1 do
write('-')
end
write('+')
else
term.setCursorPos(x1,y)
write('|')
term.setCursorPos(x2,y)
write('|')
end
end
--[GENERATE MENU]
mymenu={{},{},{}}
mymenu[1][1]={'test01',{print,'first'}}
mymenu[1][2]={'test02',{print,'second'}}
mymenu[1][3]={'temper',{print,'temper1'}}
mymenu[1][4]={'temper2',{print,'temper2'}}
mymenu[2][1]={'test03',{print,'third'}}
mymenu[2][2]={'test04',{print,'fourth'}}
mymenu[3][1]={'test05',{print,'fifth'}}
mymenu[3][2]={'test06',{print,'sixth'}}
menu2.generate(mymenu,15,x1+1,y1+1,x2-1,y2-1,'*','*')
First Generated:
Spoiler
Scrolled Right:
Spoiler
Scrolled Down:
Spoiler
Pressed enter to select (code set to simply print choice number)
Spoiler
Please note that I edited the menu API to update the clearing function and stop the syntax display causing an issue
Edited on 13 September 2012 - 06:08 AM