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

getting an error I never got whit this code before

Started by Anora, 29 July 2014 - 02:51 PM
Anora #1
Posted 29 July 2014 - 04:51 PM
I have been using this code/program from direwolf20 that he made a wille back for some time now and never had a problem whit it till now on a new server i am on.
I keep gettting this error
startup:9: attempt to index ? (a nil value)
have no clue whats wrong whit it all the code looks correct to my eye's


local data = {}
rednet.open("right")
p = peripheral.wrap("bottom")
function checkSlots(id)
   data = {}
   local slot
   local name
   local slots = p.getAllStacks()
   for i,j in pairs(slots) do
	  slot = i
	  name = j["destination"]
--	  print(name)
	  data[slot]=name
   end
   rednet.send(id,"done")
end
function removeSlot(slot)
   p.pushItem("up", slot, 1)
   rs.setOutput("left", true)
   sleep(1)
   rs.setOutput("left", false)
end
function book(slot,id)
   p.pushItem("up", slot, 1)
   turtle.select(1)
   turtle.drop()
   sleep(5)
   getBook()
   turtle.select(1)
   turtle.dropDown()
   rednet.send(tonumber(id), "done")
end
function getBook()
   turtle.suck()
end
function getNames(id)
   local nameTbl = textutils.serialize(data)
   rednet.send(tonumber(id), nameTbl)
end
while true do
   local id, msg, dis = rednet.receive()
   local newmsg = string.match(msg, "%a+")
--   print(msg)
   if newmsg == "checkSlots" then
	 checkSlots(id)
   elseif newmsg == "getNames" then
	 getNames(id)
   elseif newmsg == "remove" then
	 removeSlot(tonumber(string.match(msg, "%d+")))
	 rednet.send(id,"done")
   elseif newmsg == "books" then
	 slot = string.match(msg, "%d+")
	 book(tonumber(slot), id)
   end
end
Goof #2
Posted 29 July 2014 - 05:04 PM
local slots = p.getAllStacks()


Thats the definition of slots.

If the index is nil, it means that p.getAllStacks() somehow may return nil / a unusable value

Are you sure you are wrapping the correct block ?

Maybe i'm wrong. ( someone correct me if true )
Edited on 29 July 2014 - 03:05 PM
Anora #3
Posted 29 July 2014 - 06:26 PM
local slots = p.getAllStacks()


Thats the definition of slots.

If the index is nil, it means that p.getAllStacks() somehow may return nil / a unusable value

Are you sure you are wrapping the correct block ?

Maybe i'm wrong. ( someone correct me if true )

its a chest below the Turtle so its correct, wonder if it makes a difrence of having the iron chest mod caus this server dose not have it.
flaghacker #4
Posted 29 July 2014 - 06:31 PM
Has the server openperipherals installed? Type this in the console to test:

openp/docs bottom
Anora #5
Posted 29 July 2014 - 06:32 PM
ha the admin forgot to add that
flaghacker #6
Posted 29 July 2014 - 06:48 PM
Lol sometimes it's as easy as that.