Thalassicus
Bytes and Nibblers
Trying to retrieve a value from a table by index:
This return an error, "attempt to index local cityTable (a function value)"
Similar problem with:
This confused my brother (helping me learn Lua) as every list he's worked with has been able to use the "in pairs" mechanism. So we tried the following:
Output is:
Clearly this data is a table, yet table operations can't be used on it. It appears to be treating it as a function data type, and not the return value of the function (which is a table). How can I access indices in this table?
Code:
local cityTable = toPlayer:Cities();
local toCity = cityTable [i];
This return an error, "attempt to index local cityTable (a function value)"
Similar problem with:
Code:
for key,value in pairs(toPlayer:Cities()) do
This confused my brother (helping me learn Lua) as every list he's worked with has been able to use the "in pairs" mechanism. So we tried the following:
Code:
print(fromPlayer:Cities());
Output is:
Code:
function: 15BD4A18 table: 15899E90
Clearly this data is a table, yet table operations can't be used on it. It appears to be treating it as a function data type, and not the return value of the function (which is a table). How can I access indices in this table?