Attempt to index field 'lights' (a nil value)

Hi Guys,

I basically duplicated the code from the light demo to attempt to get light working in my game. Here’s a quick video explanation of the issue, showing the error message.

http://screencast.com/t/2U55nhlMoo

Question #1 is what am I missing? (Is there a lighting tutorial somewhere?)

Also, how does one set the initial ambient light for a level/layer?

Thank you

Hello steve67,

You have to enable lighting before loading your map. I know, that isn’t very obviously stated anywhere and the lack of tutorials doesn’t help any, but tutorials are coming! 

You can set the ambient light for a layer in Tiled using the layer properties lightRed, lightGreen, and lightBlue. You can set the map to automatically apply diminishing ambient layer light from the top of the map to the bottom using map properties. I recommend having a look at the Reserved Properties documentation.

Hello steve67,

You have to enable lighting before loading your map. I know, that isn’t very obviously stated anywhere and the lack of tutorials doesn’t help any, but tutorials are coming! 

You can set the ambient light for a layer in Tiled using the layer properties lightRed, lightGreen, and lightBlue. You can set the map to automatically apply diminishing ambient layer light from the top of the map to the bottom using map properties. I recommend having a look at the Reserved Properties documentation.