Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local Z = shell.getRunningProgram()
- if tArgs[1] == nil then
- print("Usage: "..Z.." <call> <side> <methods>")
- print("Usage: "..Z.." <check> <side>")
- error()
- end
- local function fixArgs()
- table.remove(tArgs, 1)
- table.remove(tArgs, 1)
- local vArgs = {}
- local tmp
- for i,v in ipairs(tArgs) do
- if tonumber(tArgs[i]) then tmp = tonumber(tArgs[i]) else tmp = tArgs[i] end
- table.insert(vArgs, tmp)
- end
- return vArgs
- end
- local function call(side)
- local tbl = fixArgs()
- local err = ({peripheral.call(side, unpack(tbl))})
- if err ~= nil then
- if type(err) == "string" then
- print(err)
- elseif type(err) == "table" then
- for i,v in ipairs(err) do
- print(v)
- end
- end
- end
- end
- local function check(side)
- print(peripheral.getType(side))
- print("")
- for i, v in ipairs(peripheral.getMethods(side)) do
- print(v)
- end
- end
- if tArgs[1] == "call" then
- call(tArgs[2])
- elseif tArgs[1] == "check" then
- check(tArgs[2])
- end
Add Comment
Please, Sign In to add comment