Posted 30 June 2015 - 06:23 AM
I am currently using a menu for players to select options from, but I want the menu to display in 2 columns instead of just 1. Any help is much appriciated.
edit: I don't remember who I got the original menu code from, but if this is your code, thank you!
term.clear()
local side = "back"
function pulse(color,amount,length)
for i=1, amount do
rs.setBundledOutput(side,color)
os.sleep(length)
rs.setBundledOutput(side,0)
os.sleep(length)
end
end
local function centerText(text)
local x,y = term.getSize()
local x2,y2 = term.getCursorPos()
term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
print(text)
end
term.setCursorPos(1,1)
local function menu(...) -- ver 0.1
local sel = 1
local list = {...}
while true do
if sel > #list then sel = 1 end
if sel < 1 then sel = #list end
for i = 1,#list do
term.setCursorPos(17,5+i-1)
if sel == i then
print("["..list[i].."]")
else
print(" "..list[i].." ")
end
end
while true do
local e,e1,e2,e3,e4,e5 = os.pullEvent()
if e == "key" then
if e1 == 200 then -- up key
sel = sel-1
break
end
if e1 == 208 then -- down key
sel = sel+1
break
end
if e1 == 28 then
term.setCursorPos(1,1)
return list[sel],sel
end
end
end
end
end
centerText("Please select Option")
local selection = menu("1","2","3","4","5","B")
if selection == "1" then
pulse(0,0,0)
elseif selection == "2" then
pulse(4,5,.4)
elseif selection == "3" then
pulse(4,10,.4)
elseif selection == "4" then
pulse(4,15,.4)
elseif selection == "5" then
pulse(4,20,.4)
elseif selection == "B" then
pulse(8,5,.4)
end
shell.run("startup")
edit: I don't remember who I got the original menu code from, but if this is your code, thank you!
Edited on 30 June 2015 - 04:37 AM