Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Config
- isDiselGen = true
- genPos = "right"
- redstoneControl = false
- redstoneOutputSide = "left"
- requiredPowerGenLevel = 5
- modemPos = "top"
- xOffsett = -1
- -- end of config
- term.clear()
- status = "disabled"
- powerGenLevel = 0
- gen = peripheral.wrap(genPos)
- rednet.open(modemPos)
- 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)
- cText("Inncoming brodcasts:", 16, 0)
- cText(message .. " / " .. protocol, 17, 0)
- end
- function checkMessage()
- 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 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
- senderID, message, protocol = rednet.receive()
- checkMessage()
- screen()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement