Posted 15 September 2012 - 08:23 PM
How do I make a menu border? So it would appear like this:
+———-+
| [1] |
| 2 |
| 3 |
+———-+
Also, here is my current code:
+———-+
| [1] |
| 2 |
| 3 |
+———-+
Also, here is my current code:
function clear()
term.clear()
term.setCursorPos(1,1)
end
function one()
sleep(.5)
clear()
print("Hello")
end
function two()
sleep(.5)
clear()
print("Hey")
end
function three()
sleep(.5)
clear()
print("Hi")
end
local menuOptions = {"1", "2", "3"}
local termX, termY = term.getSize()
local selected = 1
function centerText(text, termY)
term.setCursorPos(termX/2-#text/2,termY)
term.write(text)
return true
end
function start()
while true do
term.clear()
for i,v in ipairs(menuOptions) do
if i == selected then
centerText("["..v.."]", i)
else
centerText(v,i)
end
end
local id, key = os.pullEvent()
if key == 208 and selected < #menuOptions then
selected = selected + 1
elseif key == 200 and selected > 1 then
selected = selected - 1
elseif key == 28 then
return selected
end
end
end
x = start()
print()
if selected == 1 then
one()
end
if selected == 2 then
two()
end
if selected == 3 then
three()
end