Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --pastebin get wA1JZcVA startup.lua
- clutch = "right"
- monitor = peripheral.wrap("monitor_0")
- speedController = peripheral.wrap("back")
- meter = peripheral.wrap("left")
- dir = -1
- mult = 8
- name1 = "Press"
- name2 = ""
- autorpm = 0
- availableSU = 100
- enabled = false
- curSpeed = 16
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- function loop()
- --loop
- local remainingStr = string.gsub(meter.getLine(1), "%D+", "")
- availableSU = tonumber(remainingStr)
- monitor.setBackgroundColor(colors.orange)
- monitor.setTextColor(colors.black)
- monitor.setTextScale(0.5)
- monitor.setCursorPos(1,1)
- monitor.write(name1 .. " ")
- monitor.setCursorPos(1,2)
- monitor.write(name2 .. " ")
- monitor.setCursorPos(1,3)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- monitor.write("enabled: ")
- if enabled then
- monitor.setBackgroundColor(colors.green)
- monitor.setTextColor(colors.black)
- monitor.write("ON ")
- else
- monitor.setBackgroundColor(colors.red)
- monitor.setTextColor(colors.black)
- monitor.write("OFF")
- end
- monitor.setCursorPos(1,4)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- monitor.write("speed: " .. tostring(curSpeed) .. "rpm ")
- monitor.setCursorPos(1,5)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- monitor.write("power: " .. tostring(curSpeed*mult) .. "su ")
- monitor.setCursorPos(1,6)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- monitor.write("avai.: " .. tostring(availableSU) .. "su ")
- monitor.setCursorPos(1,8)
- monitor.setBackgroundColor(colors.gray)
- monitor.setTextColor(colors.white)
- monitor.write(" 8 16 32 ")
- monitor.setCursorPos(1,9)
- monitor.write(" 64 128 256 ")
- monitor.setCursorPos(1,10)
- monitor.setBackgroundColor(colors.red)
- monitor.setTextColor(colors.black)
- if enabled then
- autorpm = math.floor((availableSU + (curSpeed*mult)) / mult)
- else
- autorpm = math.floor(availableSU / mult)
- end
- if autorpm >= 256 then
- autorpm = 256
- end
- monitor.write("Auto: " .. tostring(autorpm) .. "rpm ")
- redstone.setOutput(clutch,enabled)
- speedController.setTargetSpeed(curSpeed*dir)
- end
- function generalUpdate()
- while true do
- loop()
- sleep(0.01)
- end
- end
- function respondMonitorTouched()
- while true do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- if yPos == 3 then
- enabled = not(enabled)
- end
- if yPos >= 8 and yPos <= 9 then
- if xPos >= 1 and xPos <= 5 then
- curSpeed = 8
- end
- if xPos >= 6 and xPos <= 10 then
- curSpeed = 16
- end
- if xPos >= 11 and xPos <= 15 then
- curSpeed = 32
- end
- if yPos == 9 then
- curSpeed = curSpeed * 8
- end
- end
- if yPos == 10 then
- curSpeed = autorpm
- end
- end
- end
- sleep(15)
- parallel.waitForAny(respondMonitorTouched,generalUpdate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement