Something went wrong. Try again.
System for ComputerCraft
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384local utils = { detectedSide = nil, hasRednet = false}local sides = { "front", "back", "left", "right", "top", "bottom" }local modem = nil
function utils.scanForModem() for i, v in ipairs(sides) do if peripheral.isPresent(v) then if peripheral.getType(v) == 'modem' then utils.detectedSide = v utils.hasRednet = true modem = peripheral.wrap(v) break end end endend
function utils.getModem() return modemend
function utils.openRednet() return rednet.open(utils.detectedSide)end
function utils.getTableLength(tableTg) local length = 0 for k, v in pairs(tableTg) do length = length + 1 end return lengthend
function utils.hasValue(tab, val) for i, v in ipairs(tab) do if v == val then return true end end
return falseend
function utils.fileExists(name) local f = io.open(name, 'r') if f ~= nil then io.close(f) return true else return false endend
function utils.clear() term.clear() term.setCursorPos(1, 1)end
function utils.filterTable(table, filterFunction) local output = {}
for k, v in pairs(table) do if filterFunction(v, k, table) then table.insert(output, v) end end
return outputend
function utils.split(inputstr, sep) if sep == nil then sep = "%s" end local t = {} for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do table.insert(t, str) end return tend
utils.scanForModem()if modem then utils.openRednet()end
return utils