I wanted to make an add-on on the entity, but I did not succeed.
0 replies, posted
I kept trying to copy from the addon to glow sticks (because - my addon was supposed to be on a medieval fanatic): in the end everything worked without errors, but there was not any fanlight either.
And I still tried to dbagat to understand that I'm not doing it, but in the end I just realized that the autorun works, only.
here is the folder tree
WIP
| addon.txt
|
+---lua
| +---autorun
| | \---server
| | sv_light.lua
| |
| \---entities
| \---lantern
| cl_init.lua
| init .lua
| shared.lua
|
+---materials
| \---light
| light.vtf
| Material.vmt
|
\---models
\---light
light.dx80.vtx
light.dx90.vtx
light.mdl
light.phy
light.sw.vtx
light.vvd
But the filling of lua files
But the filling of lua files
sv_light.lua:
resource.AddFile("materials/light/Material.vmt")
resource.AddFile("materials/light/light.vtf")
resource.AddFile("models/light/light.mdl")
hook.Add( "PlayerInitialSpawn", "LanternInit",
function( ply )
ply:PrintMessage( HUD_PRINTTALK, "Lantern Has been loaded" )//I was trying to //check if the add-on works at all
end )
cl_init:
include("shared.lua")
function ENT:Initialize()
end
function ENT:Draw()
self.Entity:DrawModel()
end
function ENT:Think()
local rgba = self:GetColor();
local dlight = DynamicLight( self:EntIndex() )
if ( dlight ) then
dlight.Pos = self:GetPos()
dlight.r = rgba.r
dlight.g = rgba.g
dlight.b = rgba.b
dlight.Brightness = 0
dlight.Size = 256
dlight.Decay = 0
dlight.DieTime = CurTime() + 0.05
end
end
init:
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
function ENT:Initialize()
self.Entity:SetCollisionGroup( COLLISION_GROUP_WEAPON )
self:SetModel("models/light/light.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys:IsValid() then phys:Wake() end
end
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local ent = ents.Create("lantern")
ent:SetPos( tr.HitPos + tr.HitNormal * 16 )
ent:Spawn()
ent:Activate()
return ent
end
ents.Create("prop_physics")
function ENT:OnTakeDamage(dmg)
self.Entity:Remove()
end
shared:
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Lantern"
ENT.Author = "Examnes"
ENT.Information = ""
ENT.Category = "Fun + Games"
ENT.Spawnable = true
ENT.AdminSpawnable = true
Materials and models are common and worked in folders models and materials
Help please, I'm over-amateur, but I really want to make an addon to the lamps.
Sorry, you need to Log In to post a reply to this thread.