This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Blitzninja's profile picture

[Error]Peripheral.find(side): attempt to call nil

Started by Blitzninja, 17 April 2014 - 06:31 PM
Blitzninja #1
Posted 17 April 2014 - 08:31 PM
Hi all,

So I'm testing some code out for a project I am doing and for some reason the line with

local table = peripheral.find("rcboilertankhightile")
kept return a nil error, so I decided to test it in lua interactive and I got this:

Anyone can help me with this?

NOTES:
Top = wired modem
Left = Monitor
rcboiler… = My steam boilers attached to the network.

P.S. Yes the boilers and the whole network is connected, I check this earlier with some other code and polling worked fine, it's just find peripheral.find(side) that is thorwin an "attempt to call nil" error.
Edited on 17 April 2014 - 06:33 PM
Dog #2
Posted 17 April 2014 - 08:43 PM
peripheral.find is only available in ComputerCraft 1.6 and later. Based on your CraftOS version, you are running ComputerCraft 1.5x.
Edited on 17 April 2014 - 06:44 PM
Blitzninja #3
Posted 17 April 2014 - 09:54 PM
Great…I guess I have to wait for the FTB Monster pack to update or do this manually
Dog #4
Posted 17 April 2014 - 10:18 PM
Well, you can use rs.getSides() in a loop to find it, but if you already know which sides the items are on why no just 'hard code' it? Also, a word of advice…even though you've localized your table (name "table") it's a good idea not to name it "table" - name it myTable or something other than just "table".
CometWolf #5
Posted 17 April 2014 - 10:21 PM
He's connecting it through a wired modem, so checking each side isn't really relevant.
The find funciton itself really isn't that hard to do manually, its a pure Lua implementation actually. I don't have 1.6 either, so i don't know what it is exactly, but generally people just use peripheral.getNames instead.

local tBoilers = {}
for k,v in pairs(peirpheral.getNames()) do
  peripheral.getType(v) == "rcboilertankhightile" then
    tBoilers[#tBoilers+1] = peripheral.wrap(v)
  end
end
Dog #6
Posted 17 April 2014 - 10:24 PM
He's connecting it through a wired modem, so checking each side isn't really relevant.
D'oh - embarrassed that I missed that. Thanks for setting things straight CometWolf :)/>