Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---Lift Controller
- ---Original by Baumstamm
- ---Edited by MarsGame
- ---Define Settings
- monitorSide= "top" ---where is the monitor
- liftSide= "left" ---where is the lift
- fontScale= 0.5 ---set font scale, default is perfect for 1 block widh monitors
- landTime= 3 ---how long to wait before switching back to UP-Mode
- ---Further down is the Code for the program, you don't need to change there anything, as the program should work perfectly.
- ---Check for Advanced Computer
- if not term.isColor() then
- print("Advanced computer required")
- error()
- end
- ---Set Settings
- monitor = peripheral.wrap(monitorSide)
- lift = peripheral.wrap(liftSide)
- monitor.setTextScale(fontScale)
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- ---System Variables
- liftON=""
- liftMODE="up"
- xSize, ySize = term.getSize()
- ---create Funktions
- function lift_land()
- lift.mode("down")
- liftMODE="down"
- writeToScreen()
- sleep(landTime)
- lift.mode("up")
- liftMODE="up"
- writeToScreen()
- end
- function lift_on()
- lift.enable(true)
- liftON=true
- writeToScreen()
- end
- function lift_off()
- lift.enable(false)
- liftON=false
- writeToScreen()
- end
- function startup()
- if lift.enable() then
- liftON=true
- else
- liftON=false
- end
- writeToScreen()
- end
- function writeToScreen()
- local text = "Lift Contr."
- if liftON then
- term.setBackgroundColor(colors.green)
- term.clear()
- term.setBackgroundColor(colors.red)
- term.setCursorPos((xSize/2)-(text:len()/2)+1,1)
- print(text)
- if liftMODE == "up" then
- term.setBackgroundColor(colors.lightGray)
- text="Lift Down"
- term.setCursorPos((xSize/2)-(text:len()/2)+1,3)
- print(text)
- else
- term.setBackgroundColor(colors.red)
- text="! Lift Down !"
- term.setCursorPos((xSize/2)-(text:len()/2)+1,3)
- print(text)
- end
- term.setBackgroundColor(colors.orange)
- text="Turn LIFT off"
- term.setCursorPos((xSize/2)-(text:len()/2)+1,5)
- print(text)
- else
- term.setBackgroundColor(colors.red)
- term.clear()
- term.setBackgroundColor(colors.red)
- term.setCursorPos((xSize/2)-(text:len()/2)+1,1)
- print(text)
- term.setBackgroundColor(colors.green)
- text="Turn LIFT on"
- term.setCursorPos((xSize/2)-(text:len()/2)+1,5)
- print(text)
- end
- end
- function resizeMonitor()
- while true do
- local event, side = os.pullEvent("monitor_resize")
- os.reboot()
- end
- end
- ---Start Programm
- parallel.waitForAny(resizeMonitor, startup)
- ---Check for Input
- while true do
- event,side,x,y=os.pullEvent("monitor_touch")
- if x>0 and x<xSize and y==3 and liftON then
- lift_land()
- elseif x>0 and x<xSize and y==5 and not liftON then
- lift_on()
- elseif x>0 and x<xSize and y==5 and liftON then
- lift_off()
- end
- end
Add Comment
Please, Sign In to add comment