Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Power Serv --
- rednet.open("top")
- function split(pString, pPattern)
- local Table = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pPattern
- local last_end = 1
- local s, e, cap = pString:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table,cap)
- end
- last_end = e+1
- s, e, cap = pString:find(fpat, last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table, cap)
- end
- return Table
- end
- function enableLine(side,color)
- redstone.setBundledOutput(side,colors.combine(redstone.getBundledOutput(side),color))
- end
- function disableLine(side,color)
- redstone.setBundledOutput(side,colors.subtract(redstone.getBundledOutput(side),color))
- end
- local bays = {}
- bays["bay1"] = colors.white
- local cmd = {}
- --power serv state
- function receiveState(senderID,messTab)
- local serv = messTab[2]
- local state = messTab[3]
- local servCol = bays[serbv]
- if state == "true" or state == true then
- enableLine("right",servCol)
- else
- disableLine("right",servCol)
- end
- end
- cmd["power"] = receiveState
- while true do
- senderID,message = rednet.receive(5)
- local messageTab = split(message," ")
- if cmd[messageTab[1]] then
- cmd[messageTab[1]](senderID,messageTab);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement