• OOP Issues
    0 replies, posted
So I'm trying to simulate using classes in Garry's Mod Lua. I've created the class, but cannot instantiate an object in another file even though I've included the class's file in the other file. Can anybody tell what's going wrong with the class? tss_SpriteTrail = {} tss_SpriteTrail.__index = tss_SpriteTrail function tss_SpriteTrail:new(ent, attachmentId, numberOfTrails, color, additive, startWidth, endWidth, lifetime, textureRes, texture)   local newSpriteTrail = {     ent = ent,     attachmentId = attachmentId,     numberOfTrails = numberOfTrails,     color = color,     additive = additive,     startWidth = startWidth,     endWidth = endWidth,     lifetime = lifetime,     textureRes = textureRes,     texture = texture,     infoEntities = {}   }   for i = 0, numberOfTrails, 1 do     local infoTarget = ents.Create("info_target")     infoTarget:Spawn()     infoTarget:Activate()     infoTarget:SetParent(ent, attachmentId)     infoTarget:SetLocalPos(Vector(math.random(0, 0), math.random(-10, 10), math.random(-55, 5)))     util.SpriteTrail(infoTarget, 0, color, 0, startWidth, 0, lifeTime, 1/startWidth*0.5, texture)   end   setmetatable(newSpriteTrail, tss_spriteTrail)   return newSpriteTrail end function tss_SpriteTrail:remove()   timer.Create("tss_spriteTrailRemove_"..self:EntIndex(), 5, 1, function()     SafeRemoveEntity(v)   end) end setmetatable( tss_SpriteTrail, { __call = tss_SpriteTrail.new })
Sorry, you need to Log In to post a reply to this thread.