Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Local variables ]]
- local termWidth, termHeight = term.getSize()
- local selectedItem = 1
- local a = 0 -- Current floor in block height
- local b = 0 -- Selected floor in block height
- local c = 0 -- Floor block height difference
- local d = 0 -- Absolute value of c for timer loop
- local running = true
- --[[ Menu Methods ]]
- function e() -- Math / Timer Function
- if rs.getBundledOutput("back",colors.white)==true then
- a = 0
- elseif rs.getBundledOutput("back",colors.black)== true then
- a = -5
- elseif rs.getBundledOutput("back",colors.red)== true then
- a = -10
- elseif rs.getBundledOutput("back",colors.green)== true then
- a = -15
- end -- Value of a is negative to
- c = a + b
- d = math.abs(c)
- if c > 0 then -- Timer loop to go down
- for x=1, d do
- rs.setBundledOutput("back",colors.combine(rs.getBundledOutput("back"),colors.blue))
- sleep(.2)
- rs.setBundledOutput("back",colors.subtract(rs.getBundledOutput("back"),colors.blue))
- sleep(.2)
- end
- elseif c < 0 then -- Timer loop to go up
- for x=1, d do
- rs.setBundledOutput("back",colors.combine(rs.getBundledOutput("back"),colors.gray))
- sleep(.2)
- rs.setBundledOutput("back",colors.subtract(rs.getBundledOutput("back"),colors.gray))
- sleep(.2)
- end
- elseif c == 0 then
- return
- end
- end
- function C1() -- Floor selection to give wanted height variable
- if rs.getBundledOutput("back",colors.white)==true then
- return
- else
- b = 0
- e(b)
- end
- end
- function C2()
- if rs.getBundledOutput("back",colors.black)==true then
- return
- else
- b = 5
- e(b)
- end
- end
- function C3()
- if rs.getBundledOutput("back",colors.red)==true then
- return
- else
- b = 10
- e(b)
- end
- end
- function C4()
- if rs.getBundledOutput("back",colors.green)==true then
- return
- else
- b = 15
- e(b)
- end
- end
- --[[ Menu Definitions ]]
- mainMenu = {
- [1] = { text = "1st Floor", handler = C1},
- [2] = { text = "2nd Floor", handler = C2},
- [3] = { text = "3rd Floor", handler = C3},
- [4] = { text = "4th Floor", handler = C4}
- }
- --[[ Printing Methods ]]
- function printMenu( menu )
- term.clear()
- term.setCursorPos(1,1)
- print("-=Please Select a Floor=-")
- term.setCursorPos(1,2)
- for i=1,#menu do
- if i == selectedItem then
- print(">> "..menu[i].text)
- else
- print(" "..menu[i].text)
- end
- end
- end
- --[[ Handler method ]]
- function onKeyPressed(key, menu)
- if key == 28 then
- onItemSelected(menu)
- elseif key == 200 then
- if selectedItem > 1 then
- selectedItem = selectedItem - 1
- end
- elseif key == 208 then
- if selectedItem < #menu then
- selectedItem = selectedItem + 1
- end
- end
- end
- function onItemSelected( menu )
- menu[selectedItem].handler()
- end
- --[[ Main method ]]
- function main()
- while running do
- printMenu(mainMenu)
- event, key = os.pullEvent("key")
- onKeyPressed(key,mainMenu)
- e()
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement