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

[Lua][Error] printing a table element

Started by Coal64, 21 February 2013 - 06:45 PM
Coal64 #1
Posted 21 February 2013 - 07:45 PM
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.
Lyqyd #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.
Coal64 #3
Posted 22 February 2013 - 01:25 PM
Thank you.