Thank you very much!
EDIT: but how do I fit it into my program? Can't seem to find the right place :(/>
local menuOptions = {"Brench Miner", "Quarry Miner", "Console", "Restart", "Shutdown"}
local termX, termY = term.getSize() --Get the terminal size
local selected = 1 --The selected menu item
function inserText(text, termY)
--term.setCursorPos(termX/2-#text+1/2,termY)
term.setCursorPos(16,termY+4)
term.write(text)
return true
end
function centerText(text, termY)
term.setCursorPos(termX/2-#text/2,termY)
term.write(text)
return true
end
function ingameclock()
while true do
term.clear()
local intime = textutils.formatTime(os.time(), true)
local inday = os.day()
local x = 0;
term.clear()
term.setBackgroundColor(colors.blue)
term.setCursorPos(1,2)
write(" ")
term.setBackgroundColor(colors.black)
term.setCursorPos(2,2)
if os.time() > 19 or os.time() < 6 then
term.setTextColor(colors.red)
else
term.setTextColor(colors.white)
end
write("[")
term.setTextColor(colors.white)
term.setCursorPos(3,2)
write("0")
term.setCursorPos(8-#intime,2)
write(intime)
if os.time() > 19 or os.time() < 6 then
term.setTextColor(colors.red)
else
term.setTextColor(colors.white)
end
write("]")
term.setTextColor(colors.white)
term.setCursorPos(51-12+2,2)
write("[DAY: ")
write("000")
term.setCursorPos(51-12+11-#tostring(inday),2)
write(inday)
term.setTextColor(colors.white)
write("]")
sleep(0,8)
end
end
function start()
while true do
term.setTextColor(colors.lime)
term.setBackgroundColor(colors.black)
term.setCursorPos(1,1)
centerText("Main Menu", 1)
term.setCursorPos(1,18)
term.setTextColor(colors.yellow)
print("---------------------------------------------------")
centerText("UP / DOWN - ENTER", 19)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.lightGray)
for i,v in ipairs(menuOptions) do
if i == selected then
term.setBackgroundColor(colors.orange)
term.setCursorPos(16,i+4)
write(" ")
term.setTextColor(colors.white)
inserText(i.."> "..v, i)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.lightGray)
else
inserText(i.."> "..v,i)
end
end
x,y = os.pullEvent() --Get user input
if y == keys.down and selected < #menuOptions then
selected = selected + 1
elseif y == keys.up and selected > 1 then
selected = selected - 1
elseif y == keys.enter then
return selected
end
end
end
x = start()
print()
print("You selected option: ".. menuOptions[x])
term.setTextColor(colors.green)
print("restarting program lol")
sleep(1)
term.clear()
shell.run("startmenu")