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! :D/>/>
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
...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
infunction 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
Marked the added lines. then at the top you can assign a variable to the string you want and voila!
Nice to know I could help you!
I don't think I followed the turns there, what exactly are you trying to do? Make another text on the other side but at the same line as the title?
I don't think I followed the turns there, what exactly are you trying to do? Make another text on the other side but at the same line as the title?
I figured out how to center the menu but I still need help with this.
I don't think I followed the turns there, what exactly are you trying to do? Make another text on the other side but at the same line as the title?
I figured out how to center the menu but I still need help with this.
Help with?
Btw, did you center with term.setCursorPos() or another way, if another way, how do you do it? :D/>/>
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
function printEnd(text, y)
x = 49-#text
term.setCursorPos(x,y)
write(text)
end
Is my basic idea. going to go test some stuff with it now.I got it now, think I know how to do it:Is my basic idea. going to go test some stuff with it now.function printEnd(text, y) x = 49-#text term.setCursorPos(x,y) write(text) end
EDIT: It works! :D/>/>
no because this is for a computer and a computer can have 51 characters on 1 line. this is the eaisets and msot simple way to do it. gives 3 blanksteps free space too.
just add this function at the top or something, and then call the function after the 2 lines we added before, with the y as 1 and text as whatever you want to print there