Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Power Manager
- rednet.open("back")
- 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
- local powerServers = {}
- powerServers["bay1"] = {}
- powerServers["bay1"]["serverID"] = 0
- powerServers["bay1"]["active"] = false
- function sendState(serv,state)
- rednet.send(powerSerers[serv]["serverID"],"power "..serv.." "..state)
- powerSerers[serv]["active"] = state
- end
- local cmd = {}
- --setState bay1 state
- function setState(args)
- local serv = args[2]
- local state = args[3]
- sendState(serv,sate)
- end
- cmd["setState"] = setState
- --getState bay1
- function getState(args)
- local serv = args[2]
- end
- cmd["getState"] = getState
- while true do
- senderID,message = rednet.receive(5)
- local messageTab = split(message," ")
- if cmd[messageTab[1]] then
- cmd[messageTab[1]](messageTab);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement