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

Using Pim And Tables

Started by Rangicus, 18 September 2013 - 04:53 PM
Rangicus #1
Posted 18 September 2013 - 06:53 PM
So I got the extension OpenPeripherals, and I decided to make a program that can check your inventory for a tool/weapon.
So I set up an Advanced Computer and a PIM

I then entered some code to retrieve the name of every item in my inventory including the armor slots starting from slot 0 and going to slot 39

So after standing on the PIM and opening the program I got this error (the program is call 'inv')

I believe the error is because I am trying to get a value from a serialized table but I don't know any other way to do this, hope for some help.
Bubba #2
Posted 18 September 2013 - 07:05 PM
Why are you serializing the table? Look at the documentation here. The mod returns a table so you don't have to mess with serialization at all.

Just a note, even if you did need to deal with serialization, you would want to unserialize the table not serialize it.
Rangicus #3
Posted 18 September 2013 - 07:06 PM
Why are you serializing the table? Look at the documentation here. The mod returns a table so you don't have to mess with serialization at all.
Ill look into it, thanks.
Anavrins #4
Posted 18 September 2013 - 07:07 PM
There's no need to serialize getStackInSlot(), serialization basically turns a table into a string, and you can't do something like "inv["name"]" on a string.
Changing it to "inv = p.getStackInSlot(i)" should do the job.
Edited by
Rangicus #5
Posted 18 September 2013 - 07:13 PM
Yup it worked fine thanks, if an admin can close this thatd be good.
Bubba #6
Posted 18 September 2013 - 07:23 PM
Yup it worked fine thanks, if an admin can close this thatd be good.

Glad it worked for you. We always leave threads open so that the user can come back if they have another question, or in case someone else ends up having a similar question and wants clarification.