I have a little problem with calling a function inside a function from the same API.
system/APIs/peripheralAPI:
function getPeripheralSideByType(peripheralType) return getPeripheralSideByType(peripheralType, count) end function getPeripheralSideByType(peripheralType, count) local peripheralFound = 0 for i = 1, 6, 1 do if peripheralType == peripheral.getType(rs.getSides()[i]) then peripheralFound = peripheralFound + 1 if peripheralFound == count then return rs.getSides()[i] end end end return nil end function getPeripheralByType(peripheralType) return getPeripheralByType(peripheralType, 1) end function getPeripheralByType(peripheralType, count) if getPeripheralSideByType(peripheralType, count) == nil then return nil else return peripheral.wrap(getPeripheralSideByType(peripheralType, count)) end end
test:
peripheralAPI.getPeripheralByType("monitor", 1) -- returns table peripheralAPI.getPeripheralByType("monitor") -- returns nil
Pls Help!