Page 1 of 1
can't read solar panels?
Posted: Wed Feb 22, 2017 3:14 am
by withers
Can someone tell me what's wrong with this?
for a, solar in pairs(data.raw.solar-panel) do
I keep getting "...unable to perform arithmetic on field 'solar' (a nil value)"
Re: can't read solar panels?
Posted: Wed Feb 22, 2017 3:35 am
by daniel34
withers wrote:for a, solar in pairs(data.raw.solar-panel) do
The dash in the solar-panel makes this not a valid Lua identifier (Lua thinks it's a minus sign and tries arithmetic on it), you need to use a different syntax:
Code: Select all
for a, solar in pairs(data.raw["solar-panel"]) do
Re: can't read solar panels?
Posted: Wed Feb 22, 2017 3:55 am
by withers
daniel34 wrote:withers wrote:for a, solar in pairs(data.raw.solar-panel) do
The dash in the solar-panel makes this not a valid Lua identifier (Lua thinks it's a minus sign and tries arithmetic on it), you need to use a different syntax:
Code: Select all
for a, solar in pairs(data.raw["solar-panel"]) do
That did it. Thanks!