Jump to content




index expected, got nil


  • You cannot reply to this topic
2 replies to this topic

#1 augustas656

  • Members
  • 158 posts

Posted 10 July 2013 - 04:37 PM

I need help with tables, I want to insert a value into a table that exists within a table.
for example:
a = {}
a[1] = {x = 5, y = 4}
print(a[1][x])
gives me just a blank space.
Is there any way of me inserting like so without using textutils.serialize?
I got an error for a code I was using
a = {}
a[1][x] = 5
and it said "index expected, got nil"

#2 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 10 July 2013 - 04:58 PM

local a = {}
a[1] = {}
a[1]["x"] = 5 -- OR:
a[1].x = 5

It needs to be a table in short

#3 augustas656

  • Members
  • 158 posts

Posted 11 July 2013 - 11:22 AM

THANK YOU!!! I could've found this out myself, although I was kinda lazy, but this didn't just help me with the script I had a problem with, now 3 different things that are really complex are extremely more easier to understand for me!!!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users