That is my program(credit to rondouglas) and I was wondering how to add a title above the menu.
In the picture below, above Open Stairs I wish to have a title but I can't figure out how to do it.
Thank you to whoever can help!
Posted 17 October 2012 - 12:55 PM
Posted 17 October 2012 - 01:02 PM
function main()
while running do
term.clear()
term.setCursorPos(1,1) -- added
print(title) --added
term.setCursorPos(1,2)
printMenu(mainMenu)
event, key = os.pullEvent("key")
onKeyPressed(key, mainMenu)
end
end
Posted 17 October 2012 - 01:02 PM
...snip...
--[[ Main Methods ]]--
function main()
while running do
term.clear()
term.setCursorPos(1,1) -- << These two lines
print("Your Title Here") -- <<
term.setCursorPos(1,2)
printMenu(mainMenu)
event, key = os.pullEvent("key")
onKeyPressed(key, mainMenu)
end
end
Posted 17 October 2012 - 01:04 PM
Doyle3694, on 17 October 2012 - 01:02 PM, said:
function main()
while running do
term.clear()
term.setCursorPos(1,1) -- added
print(title) --added
term.setCursorPos(1,2)
printMenu(mainMenu)
event, key = os.pullEvent("key")
onKeyPressed(key, mainMenu)
end
end
Posted 17 October 2012 - 01:05 PM
Posted 17 October 2012 - 01:15 PM
Doyle3694, on 17 October 2012 - 01:05 PM, said:
Posted 17 October 2012 - 01:28 PM
Posted 17 October 2012 - 01:30 PM
Posted 17 October 2012 - 01:43 PM
sIdEkIcK_, on 17 October 2012 - 01:40 PM, said:
local cPrint = function(text)
local x2,y2 = term.getCursorPos()
local x,y = term.getSize()
term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
print(text)
end
function printMenu(menu)
for i = 1, #menu do
if i == selectedItem then
cPrint("[ "..menu[i].text.." ]")
else
cPrint(""..menu[i].text)
end
end
end
Posted 17 October 2012 - 01:43 PM
function printEnd(text, y) x = 49-#text term.setCursorPos(x,y) write(text) endIs my basic idea. going to go test some stuff with it now.
Posted 17 October 2012 - 01:52 PM
Doyle3694, on 17 October 2012 - 01:43 PM, said:
function printEnd(text, y) x = 49-#text term.setCursorPos(x,y) write(text) endIs my basic idea. going to go test some stuff with it now.
Posted 17 October 2012 - 02:03 PM
Posted 17 October 2012 - 02:06 PM
Doyle3694, on 17 October 2012 - 02:03 PM, said:
Posted 17 October 2012 - 02:09 PM
0 members, 1 guests, 0 anonymous users