This is the code for an entity called ent_jack_radiation
it's an invisible point entity that does damage to players and NPCs
Whenever I call on it, the game says it doesn't exist, even though it returns no errors when I run the files with lua_openscript_cl
init.lua
[lua]
function ENT:Initialize()
--We need to init physics properties even though this entity isn't physically simulated
self.Entity:SetMoveType( MOVETYPE_NONE )
self.Entity:DrawShadow( false )
self.Entity:SetCollisionBounds( Vector( -20, -20, -10 ), Vector( 20, 20, 10 ) )
self.Entity:PhysicsInitBox( Vector( -20, -20, -10 ), Vector( 20, 20, 10 ) )
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:EnableCollisions( false )
end
self.Entity:SetNotSolid( true )
--remove this ent after awhile
self.Entity:Fire("kill","",8)
self.StartTime=CurTime()
self.Pos=self:GetPos()
end
function ENT:Think()
local RadIntensity=((8-(CurTime()-self.StartTime))/8)
for key,found in pairs(ents.FindInSphere(self.Pos,2000)) do
local Distance=(found:GetPos()-self.Pos):Length()
local Damage=RadIntensity*((2000-Distance)/2000)
if((found:IsValid())and(((found:IsNPC())or(found:IsPlayer()))and(found:Alive())))then
found:TakeDamage(Damage*10)
if(found:IsPlayer())then
local num=math.random(1,3)
found:EmitSound("lolsounds/geiger"..num..".wav")
end
end
end
self:NextThink(CurTime()+0.3)
end
[/lua]
shared.lua
[lua]
ENT.Type = "point"
ENT.PrintName = "Neutron Radiation"
ENT.Author = "Jackarunda"
ENT.Spawnable = false
ENT.AdminSpawnable = false
[/lua]
ENT.Base = "base_point"
In shared.lua
Um, I changed that and gmod still says it's a nil ent...
[QUOTE=Jackarunda;25121355]even though it returns no errors when I run the files with lua_openscript_cl
[/QUOTE]
You must be doing it wrong. It SHOULD give an error if you try to run an entity script directly, since it is trying to add on to an ENT table that doesn't exist.
I got it.
I forgot to put "include('shared.lua')" at the top.
*Facepalm*
Sorry, you need to Log In to post a reply to this thread.