Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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].."]") print(">"..list[i])
- else
- print(" "..list[i].." ")
- 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
- local function book(a)
- local side = "back"
- local color = {...}
- redstone.setBundledOutput(side, color) -- stored space line
- sleep(1)
- redstone.setBundledOutput(side, 0) -- reset all lines to no power
- sleep(5) -- give the player time to use it
- redstone.setBundledOutput(side, colors.purple) -- send back to storage space
- sleep(1)
- redstone.setBundledOutput(side, 0)
- end
- print("Please select a destination")
- while true do
- local selection = menu("1","2","3","4","5","6","7","8")
- if selection == "1" then
- book(colors.blue)
- elseif selection == "2" then
- book(colors.white)
- elseif selection == "3" then
- book(colors.lightgrey)
- elseif selection == "4" then
- book(colors.lightblue)
- elseif selection == "5" then
- book(colors.red)
- elseif selection == "6" then
- book(colors.pink)
- elseif selection == "7" then
- book(colors.yellow)
- elseif selection == "8" then
- book(colors.brown)
- end
Advertisement
Add Comment
Please, Sign In to add comment