Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(pString, pPattern)
- local Table = {}
- 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
- args = {...}
- action = args[1] or "error"
- TYPE_WARP = "warpcore"
- if action=="on" or action=="off" then
- local mode = 0
- if action=="on" then
- mode = 1
- end
- local peripherals = peripheral.getNames()
- for i = 1,#peripherals do
- if peripheral.getType(peripherals[i]) == TYPE_WARP then
- local core = peripheral.wrap(peripherals[i])
- core.set_mode(mode)
- local id = split(peripherals[i],"_")
- if #id>1 then
- id = '#'..id[2]
- else
- id = 'at '..peripherals[i]
- end
- print("WarpCore "..id.." powered "..action)
- end
- end
- else
- print("Usage: warpctl <on|off>")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement