matiasah / shadows

Shädows - A Shadows & Lights engine for löve

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nil xcp when resizing

Sungray opened this issue · comments

LightWorld.lua, line 37, when no stars are created

        for Index, Light in pairs(self.Stars) do
            
            Light:Resize(Width, Height)
            
        end

should be

    if(self.Stars) then
        for Index, Light in pairs(self.Stars) do
            
            Light:Resize(Width, Height)
            
        end
    end

Did you mean

if next(self.Stars) then

The condition you mentioned there only checks that the table self.Stars exists, which is always is true because it's initialized in the constructor.

Unless you're calling directly

LightWorld:Resize(w, h)

(Instead of calling newLightWorld:Resize)

local LightWorld = require("shadows.LightWorld")
local newLightWorld = LightWorld:new()

newLightWorld:Resize(w, h)

Which is a common mistake that I often do.

Yess, my mistake, you're exactly right, was calling LightWorld. Thanks !