title: [Lua][Error] printing a table element
I keep geting a error, "program:2: attempt to call table" I am just starting lua, I did search but did not find what I was looking for.
the code is:
local table = {"top", "bottom"}
print(table(2))
all I am trying to do is print "bottom" that will be used in with other things.
[Lua][Error] printing a table element
Started by Coal64, Feb 21 2013 07:45 PM
2 replies to this topic
#1
Posted 21 February 2013 - 07:45 PM
#2
Posted 22 February 2013 - 04:58 AM
Split into new topic.
Use [] instead of (). () are used for function calls, [] are used for indexing tables. They are not interchangeable. So, `print(table[2])`. And don't name your tables "table", since you're overwriting the table library.
Use [] instead of (). () are used for function calls, [] are used for indexing tables. They are not interchangeable. So, `print(table[2])`. And don't name your tables "table", since you're overwriting the table library.
#3
Posted 22 February 2013 - 01:25 PM
Thank you.
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











