Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = nil
- local compressor = nil
- local diskSide = nil
- local outSide = nil
- while monitor == nil or compressor == nil or diskSide == nil do
- for _, side in ipairs(rs.getSides()) do
- if peripheral.isPresent(side) then
- if peripheral.getType(side) == "monitor" then
- monitor = peripheral.wrap(side)
- elseif peripheral.getType(side) == "drive" then
- diskSide = side
- elseif string.gmatch(peripheral.getType(side), "compressor") then
- compressor = peripheral.wrap(tostring(side))
- outSide = side
- end
- end
- end
- end
- print("Peripherals found")
- local targetPressure = 0
- if disk.getLabel(diskSide) ~= "Floppy Disk" and disk.getLabel(diskSide) ~= nil then
- print(disk.getLabel(diskSide))
- targetPressure = tonumber(disk.getLabel(diskSide))
- end
- local currentPressure = 0
- local change = true
- monitor.clear()
- while true do
- if change then
- monitor.clear()
- currentPressure = compressor.getPressure()
- if currentPressure < targetPressure then
- rs.setOutput(outSide, true)
- --print(currentPressure)
- else
- rs.setOutput(outSide, false)
- end
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1, 3)
- monitor.setTextColor(colors.red)
- monitor.write("-")
- monitor.setCursorPos(7, 3)
- monitor.setTextColor(colors.green)
- monitor.write("+")
- local newString = string.format("%.1f", targetPressure)
- monitor.setCursorPos((math.ceil(3 - (newString:len())/2))+1, 3)
- monitor.setTextColor(colors.white)
- monitor.write(newString)
- end
- os.startTimer(.1)
- local _1, _2, xpos, ypos = os.pullEvent()
- if currentPressure ~= compressor.getPressure() then
- change = true
- end
- if xpos == 1 and ypos == 3 then
- change = true
- targetPressure = targetPressure - 0.1
- disk.setLabel(diskSide, tostring(targetPressure))
- elseif xpos == 7 and ypos == 3 then
- change = true
- targetPressure = targetPressure + 0.1
- disk.setLabel(diskSide, tostring(targetPressure))
- end
- end
Add Comment
Please, Sign In to add comment