Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Config
- isDiselGen = true
- redstoneControl = false
- redstoneOutputSide = "left"
- requiredPowerGenLevel = 4
- modemPos = "top"
- xOffsett = -1
- -- end of config
- local gen = peripheral.wrap("right")
- rednet.open(modemPos)
- local powerSpace = "No message received"
- function cText(text, yPos, xOff)
- x,y = term.getSize()
- xPos = (x - string.len(text))/2 - xOffsett - xOff
- term.setCursorPos(xPos,yPos)
- print(text)
- end
- function screen()
- term.clear()
- cText("PowerController by _TheSettler_", 2, 0)
- cText("Recived power gen level:" .. powerGenLevel, 4, 0)
- cText("Status: " .. status, 5, 0)
- end
- function getUpdate()
- senderID, message, protocol = rednet.receive()
- if protocol == "powerGenLevel" then
- if message = 1 then
- powerGenLevel = 1
- elseif message = 2 then
- powerGenLevel = 2
- elseif message = 3 then
- powerGenLevel = 3
- elseif message = 4 then
- powerGenLevel = 4
- else
- status = "Error: No PowerLevel"
- end
- end
- if tostring(powerGenLevel) == "Error: No PowerLevel"
- break
- elseif requiredPowerGenLevel < powerGenLevel then
- status = "Activated"
- else
- status = "Deactivated"
- end
- controlPower()
- end
- function isNumeric(value)
- if tonumber(value) ~= nil then
- return true
- else
- return false
- end
- end
- function controlPower()
- if isDiselGen = true then
- if status == "Activated" then
- gen.setEnabled(true)
- else
- gen.setEnabled(false)
- end
- end
- if redstoneControl = true then
- if status == "Activated" then
- redstone.setOutput(redstoneOutputSide, false)
- else
- redstone.setOutput(redstoneOutputSide, false)
- end
- end
- end
- while true do
- screen()
- getUpdate()
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement