Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("APPARATO CENTRALE COMPUTERIZZATO - SALEKHARD")
- print("")
- print("Engine running:")print(redstone.getInput("back"))
- local tOptions = {"Deviato", "Corr. Tracc.", "TLBCA PB11"} -- Add menu options here.
- local selection = 1
- while true do
- term.clear()
- x,y = term.getSize()
- y = (y - #tOptions)/2
- term.setCursorPos(x,y)
- for i = 1, #tOptions do
- if i == selection then
- scrap,y = term.getCursorPos()
- x, scrap = term.getSize()
- x = (x-#tOptions[i])/2 - 3
- term.setCursorPos(x,y)
- print(">> "..tOptions[i].." <<")
- else
- scrap,y = term.getCursorPos()
- x, scrap = term.getSize()
- x = (x-#tOptions[i])/2
- term.setCursorPos(x,y)
- print(tOptions[i])
- end
- end
- event, key = os.pullEvent("key")
- if key == 208 or key == 31 then
- selection = selection + 1
- end
- if key == 200 or key == 17 then
- selection = selection - 1
- end
- if selection > #tOptions then
- selection = 1
- end
- if selection < 1 then
- selection = #tOptions
- end
- end
- local function menu(...)
- local sel = 1
- local list = {...}
- local offX,offY = term.getCursorPos()
- local curX,curY = term.getCursorPos()
- while true do
- if sel > #list then sel = 1 end
- if sel < 1 then sel = #list end
- for i = 1,#list do
- term.setCursorPos(offX,offY+i-1)
- if sel == i then
- print("["..list[i].."]") -- very customisible example print(">"..list[i])
- else
- print(" "..list[i].." ") -- very customisible
- 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(curX,curY)
- return list[sel],sel
- end
- end
- end
- end
- end
- function Option1()
- redstone.setOutput("back", true)
- print("Starting engine...")
- sleep(2)
- end
- function Option2()
- redstone.setOutput("back", false)
- print("Stopping engine...")
- sleep(2)
- end
- function Option3()
- redstone.setOutput("left", true)
- print("Door opened")
- sleep(5)
- redstone.setOutput("left", false)
- end
- while true do
- local selection = menu(
- "Option 1",
- "Option 2",
- "Option 3")
- if selection == "Option 1" then
- Option1()
- elseif selection == "Option 2" then
- Option2()
- elseif selection == "Option 3" then
- Option3()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment