Light = {} LoadedObjects.Lights = {} function Light:New(x,y,range,flicker,color,lum) local o = {} o.pos = { x = x, y = y } o.range = range o.lum = lum or 1 o.color = color or {1,1,1} o.flicker_value = flicker or 2 o.flicker = 0 o.dim = 0 o.flicker_time = 60/12 o.flicker_timer = 0 table.insert(LoadedObjects.Lights,o) o.id = #LoadedObjects.Lights setmetatable(o, self) self.__index = self return o end function Light:Kill() if self.id ~= nil then for _, e in pairs(LoadedObjects.Lights) do if e.id > self.id then e.id = e.id - 1 end end table.remove(LoadedObjects.Lights,self.id) end self = nil end function Light:Flicker() self.flicker_timer = self.flicker_timer + 1 if self.flicker_timer >= self.flicker_time then self.flicker_timer = self.flicker_timer - self.flicker_time self.flicker = math.random(0,1) self.flicker = math.min(math.max(self.flicker, -self.flicker_value), self.flicker_value) end end