can't read solar panels?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
withers
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Apr 08, 2016 4:54 pm
Contact:

can't read solar panels?

Post 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)"

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: can't read solar panels?

Post 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
quick links: log file | graphical issues | wiki

User avatar
withers
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Apr 08, 2016 4:54 pm
Contact:

Re: can't read solar panels?

Post 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!

Post Reply

Return to “Modding help”