Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This is written by me. If you see this, feel free to suggest new ideas for more functions to fit in with this API on the forums!
- --Just waits for events and prints the event name, and its parameters out all nicely
- function eventSniff()
- while true do
- local ev = {os.pullEvent()}
- for k,v in pairs(ev) do
- if k == 1 then
- print("Event Name : "..v)
- else
- print("param "..(k-1).." : "..v)
- end
- end
- end
- end
- --Checks every side for a peripheral and if there is one, it prints the type of peripheral as well as the methods for it
- function checkAllPeripheral()
- for k,v in pairs(rs.getSides()) do
- if peripheral.isPresent(v) then
- print("Side: "..v)
- print("Type: "..peripheral.getType(v))
- print("Methods: ")
- for k2,v2 in pairs(peripheral.getMethods(v)) do
- print(v2)
- end
- end
- end
- end
- --Checks every side for a specified peripheral (name variable) and if it is present, it'll return the side it is present on. Varname is optional and all you'd do is put a string there for example "p" and if it finds the peripheral you're looking for, it'll automatically wrap it to that string (p = peripheral.wrap("left"))
- function peripheralGet(name,varname)
- for k,v in pairs(rs.getSides()) do
- if peripheral.getType(v) == name then
- if varname ~= nil then
- local tb1 = {}
- tb1[varname] = peripheral.wrap(v)
- return true
- else
- return v
- end
- end
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment