Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MASTER_CHANNEL = 5452
- ELEVATOR_CHANNEL = 47883
- LABEL = os.getComputerLabel()
- REDSTONE = true
- modem = peripheral.find("modem")
- modem.open(ELEVATOR_CHANNEL)
- function splitString(str, delimiter)
- local result = {}
- local startIndex = 1
- local delimiterIndex = string.find(str, delimiter, startIndex, true)
- while delimiterIndex do
- local part = string.sub(str, startIndex, delimiterIndex - 1)
- table.insert(result, part)
- startIndex = delimiterIndex + 1
- delimiterIndex = string.find(str, delimiter, startIndex, true)
- end
- local lastPart = string.sub(str, startIndex)
- table.insert(result, lastPart)
- return result
- end
- function jobs(calledTask)
- if calledTask == "call" then
- if REDSTONE == true then
- REDSTONE = false
- else
- REDSTONE = true
- end
- end
- end
- while true do
- if REDSTONE == true then
- redstone.setOutput("bottom", true)
- else
- redstone.setOutput("bottom", false)
- end
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- local transmission = message
- local delimiter = " "
- local result = splitString(transmission, delimiter)
- if result[2] == LABEL then
- jobs(result[1])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement