Test lua sent not spawning

I made my first sent, It shows up in the entity menu but when I click it nothing happens. There are no lua errors or anything like that.

the path that I set up is

root/addons/Test/lua/entiities/sent_dt/

Here are the files:
init.lua



AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")



local Model = ( "models/Items/item_item_crate.mdl" )




function ENT:SpawnFunction(ply, tr)
	if not tr.Hit then return end
	
		local SpawnPos = tr.HitPos + tr.HitNormal*16
		local ent = ents.Create("sent_dt")
			ent:SetPos(SpawnPos)
			ent:SetVar("Owner",ply)
			ent:Spawn()
			ent:Activate()
			return ent
end

function ENT:Initialize()

	self.Entity:SetModel(Model)
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)	
	self.Entity:SetSolid(SOLID_VPHYSICS)
	self.Entity:SetUseType(SIMPLE_USE)
	
	local phys = self.Entity:GetPhysicsObject()
		if phys:IsValid() then
			phys:Wake()
		end
	
	self.Position = Vector()
	self.Activated = false
end


function ENT:Use(activator, caller)

	if ( activator:IsPlayer() ) then
		if ( activator:Health() <= 100) then
			local health = activator:Health()
			activator:SetHealth( health + 10 )
		else return end
	end
end	

function ENT:Think()

end

function ENT:OnRemove()

end

function ENT:OnTakeDamage(dmg)
	self.Entity:TakePhysicsDamage(dmg)
		local randColour1 = (50,50,200,255)
		local randColour2 = (200,50,50,255)
		local randColour3 = (50,200,50,255)
			ent:SetColor(randColour +math.random(3))
	end	
		
	




 function ENT:Touch( hitEnt )
 	if ( hitEnt:IsValid() and hitEnt:IsPlayer() ) then
		
		for k,v in pairs(player.GetAll()) do
			if ( v != hitEnt ) then
				v:ChatPrint( HUD_PRINTCENTER, hitEnt:Nick() .. " Touched the box and is now dead." )
				else 
					v:ChatPrint( HUD_PRINTCENTER, "You touched the box, now die!!" )
			end
		end
 		hitEnt:Kill()
	end
end









shared.lua





ENT.Type 			= "anim"
ENT.PrintName		= "Test"
ENT.Author			= "Vexx"

ENT.Spawnable			= true
ENT.AdminSpawnable		= false


What’s wrong?

You forgot your client file to tell it to draw the entity

cl_init.lua



ENT.Spawnable			= true
ENT.AdminSpawnable		= true
include('shared.lua')


function ENT:Initialize()

end

function ENT:Draw()
	
	self.Entity:DrawModel()

end


?? weird, some how the cl_init disappeared from the post.

Here:



ENT.Spawnable			= true
ENT.AdminSpawnable		= true

include('shared.lua')

function ENT:Initialize()

end

function ENT:Draw()

	self.Entity:DrawModel()

end

function ENT:OnRemove()

end








function ENT:Initialize()

	self.Entity:SetModel(Model)
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)	
	self.Entity:SetSolid(SOLID_VPHYSICS)
	self.Entity:SetUseType(SIMPLE_USE)
	
	local phys = self.Entity:GetPhysicsObject()
		if phys:IsValid() then
			phys:Wake()
		end
	
	self.Position = Vector()
	self.Activated = false
end


You didn’t specify which model you just set the model as Model.

What do you mean?

self.Entity:SetModel(Model)
This needs to be the path to a model.

Yeah I do, look at the first line of initialize.

Ehhh
[lua]local Model = ( “models/Items/item_item_crate.mdl” )[/lua]
At the top

[editline]09:24[/editline]
Ninja’d

Oh wait, I went through the console carfully and I found this:

entities/sent_dt/init.lua:57: ‘)’ expected near ‘,’
Folder = entities/sent_dt
Couldn’t register Scripted Entity sent_dt - the Type field is empty!

[editline]01:35AM[/editline]

Here are the new codes:

init.lua


AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")



local model = ( "models/Items/item_item_crate.mdl" )
local ent = ents.Create("prop_physics")



function ENT:SpawnFunction(ply, tr)
	if not tr.Hit then return end
	
		local SpawnPos = tr.HitPos + tr.HitNormal*16
			ent:SetPos(SpawnPos)
			ent:SetVar("Owner",ply)
			ent:Spawn()
			ent:Activate()
			return ent
end

function ENT:Initialize()

	self.Entity:SetModel(model)
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)	
	self.Entity:SetSolid(SOLID_VPHYSICS)
	self.Entity:SetUseType(SIMPLE_USE)
	local phys = self.Entity:GetPhysicsObject()
		if phys:IsValid() then
			phys:Wake()
		end
end


function ENT:Use(activator, caller)

	if ( activator:IsPlayer() ) then
		if ( activator:Health() < 81) then
			local health = activator:Health()
			activator:SetHealth( health + 10 )
		else return end
	end
end	

function ENT:Think()

end

function ENT:OnRemove()

end

function ENT:OnTakeDamage(dmg)
	self.Entity:TakePhysicsDamage(dmg)
		local randColour1 = (50,50,200,255)
		local randColour2 = (200,50,50,255)
		local randColour3 = (50,200,50,255)
			ent:SetColor(randColour +math.random(3))
	end	
		
	




 function ENT:Touch( hitEnt )
 	if ( hitEnt:IsValid() and hitEnt:IsPlayer() ) then
		
		for k,v in pairs(player.GetAll()) do
			if ( v != hitEnt ) then
				v:ChatPrint( HUD_PRINTCENTER, hitEnt:Nick() .. " Touched the box and is now dead." )
				else 
					v:ChatPrint( HUD_PRINTCENTER, "You touched the box, now die!!" )
			end
		end
 		hitEnt:Kill()
	end
end








cl_init.lua


ENT.Spawnable			= true
ENT.AdminSpawnable		= true

include('shared.lua')

function ENT:Initialize()

end

function ENT:Draw()

	self.Entity:DrawModel()

end

function ENT:OnRemove()

end






shared.lua




ENT.Type 			= "anim"
ENT.PrintName		= "Test"
ENT.Author			= "Vexx"

ENT.Spawnable			= true
ENT.AdminSpawnable		= false


The only other problem I can see is the OnTakeDamage()



function ENT:OnTakeDamage(dmg)
	self.Entity:TakePhysicsDamage(dmg)
		local randColour1 = (50,50,200,255)
		local randColour2 = (200,50,50,255)
		local randColour3 = (50,200,50,255)
			ent:SetColor(randColour +math.random(3))
	end


For 1 ent should be self.entity
For 2 randColour +math.random(3) does not make randColour1 or randColour2 or RandColour3 atleast I dont think it does. You should do it like this.

local Colour1 = (50,50,200,255)
local Colour2 = (200,50,50,255)
local Colour3 =(50,200,50,255)
local randColour = {Colour1, Colour2, Colour3}
self.Entity:SetColor(table.Random(randColour))

But if I’m wrong about all that then you should look for errors in your console or just copy your whole console and paste it here.

Edit* you might have to make the Colours be like this. Colour1= Color(50,50,200,255)

Here is my console:


Mounting hl2.. OK
Mounting ep2.. OK
Mounting tf.. OK
Mounting cstrike.. OK
Mounting dod.. Not Mounting dod (no access)
No permission
Mounting episodic.. OK
Mounting hl2mp.. OK
Mounting portal.. OK
Mounting lostcoast.. Disabled
Mounting hl1.. Not Mounting hl1 (no access)
No permission
Mounting hl1mp.. Disabled
Mounting zeno_clash.. Not Mounting zeno_clash (no access)
No permission
KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file addons/Faith_nude/info.txt
AddonInfo, 
KeyValues Error: RecursiveLoadFromBuffer:  got NULL key in file addons/gm_Hzb_FlatgrassFINAL/info.txt
AddonInfo, 
KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file addons/gm_proudstruct/info.txt
AddonInfo, 
Error, bad server command sv_allow_voice_from_file 0
Parent cvar in server.dll not allowed (sk_apc_missile_damage)
Garry's Mod client.dll Build #072 [Nov 20 2009 20:20:42]
maxplayers set to 128
Steam config directory: c:\program files\steam\steamapps\vexx21322\garrysmod\platform\config
Convar r_rootlod has conflicting FCVAR_CHEAT flags (child: FCVAR_CHEAT, parent: no FCVAR_CHEAT, parent wins)
Convar r_eyeglintlodpixels has conflicting FCVAR_CHEAT flags (child: FCVAR_CHEAT, parent: no FCVAR_CHEAT, parent wins)
Convar r_skin has conflicting FCVAR_CHEAT flags (child: no FCVAR_CHEAT, parent: FCVAR_CHEAT, parent wins)
Convar mat_softwareskin has conflicting FCVAR_CHEAT flags (child: no FCVAR_CHEAT, parent: FCVAR_CHEAT, parent wins)
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function render_blobs
Didn't find particle function lennard jones force
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Didn't find particle function Rotation Orient Relative to CP
Garry's Mod server.dll Build #072 [Nov 20 2009 20:20:38]
maxplayers set to 1
Unknown command "sv_backspeed"
Unknown command "Vexx"
GetAllManifestFiles:  Unable to load maplist.txt
--- Missing Vgui material vgui/..\vgui\icon_con_high
--- Missing Vgui material vgui/../vgui/icon_con_high.vmt
maxplayers set to 1
Unknown command "sv_rollangle"
Unknown command "sv_unlag_fixstuck"
Failed, using default cubemap 'engine/defaultcubemap'
Failed, using default cubemap 'engine/defaultcubemap'
Failed, using default cubemap 'engine/defaultcubemap'
Failed, using default cubemap 'engine/defaultcubemap'
Failed, using default cubemap 'engine/defaultcubemap'
Failed, using default cubemap 'engine/defaultcubemap'
Failed, using default cubemap 'engine/defaultcubemap'
Failed, using default cubemap 'engine/defaultcubemap'
Failed, using default cubemap 'engine/defaultcubemap'
Lua initialized (Lua 5.1)
======== Installing Table (De)Serialiser Module | ver: 1.4 ========
====================
Armor fix installed, but not needed in singleplayer.
====================
autorun/entities.lua:25: '}' expected (to close '{' at line 11) near 'KeyValues'
================================
===  Wire  2060   Installed  ===
================================
======== Beam NetVars Lib v0.71 Installed ========
ERROR! Module 'zlib_b64' not found!
==== Advanced Duplicator v.1.72 shared module installed! ====
==== Advanced Duplicator v.1.85 server module installed! ====
Registering gamemode 'sandbox' derived from 'base'
ScriptEnforce is disabled
Loading Wire Tools
entities/gmod_perimeterturret/init.lua:140: 'then' expected near 'thenself'
Folder	=	entities/gmod_perimeterturret
Couldn't register Scripted Entity gmod_perimeterturret - the Type field is empty!
Skipping E2 extension 'propcore'.
entities/immolate/init.lua:5: attempt to index global 'EFFECT' (a nil value)
Folder	=	entities/immolate
Couldn't register Scripted Entity immolate - the Type field is empty!
Executing listen server config file
Door switch3 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch6 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch8 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch4 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch11 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch13 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch1 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch7 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch2 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch5 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch0 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch10 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
Door switch12 using obsolete 'Start Open' spawnflag with 'Spawn Position' set to 'Open'. Reverting to old behavior.
exec: couldn't exec listenserver.cfg
InitFastCopy: only 51% fast props. Bug?
Lua initialized (Lua 5.1)
======== Installing Table (De)Serialiser Module | ver: 1.4 ========
====================
Armor fix installed, but not needed in singleplayer.
====================
autorun/entities.lua:25: '}' expected (to close '{' at line 11) near 'KeyValues'
RunConsoleCommand blocked - sent before player spawned (sv_tags)
======== Beam NetVars Lib v0.71 Installed ========
--- Missing Vgui material ignore_this_error
loading materials
loading material: cable/rope_icon
loading material: cable/cable2
loading material: cable/xbeam
loading material: cable/redlaser
loading material: cable/blue_elec
loading material: cable/physbeam
loading material: cable/hydra
loading material: arrowire/arrowire
loading material: arrowire/arrowire2
=== Loading Wire Model Packs ===
	Loaded: PHXWireModels.txt
	Loaded: default.txt
	Loaded: expression2.txt
	Loaded: cheeze_buttons2.txt
	Loaded: wire_model_pack_1.txt
	Loaded: wire_model_pack_1plus.txt
	Adding Cheeze's Buttons Pack
	Adding various Buttons from HL2 and Portal
	Jaanus' Thruster Pack
	Beer's Model pack
ERROR! Module 'zlib_b64' not found!
==== Advanced Duplicator v.1.72 shared module installed! ====
==== Advanced Duplicator v.1.741 client module installed! ====
--- Missing Vgui material humanhead
Registering gamemode 'sandbox' derived from 'base'
Loading Wire Tools
--- Missing Vgui material texturemissing
--- Missing Vgui material weapons/smodpunchicon
SWEP (weapon_m24tact) is derived from non existant SWEP (rg_base) - Expect errors!ERROR: Trying to derive entity sent_rg_bullet from non existant entity base_point!
Sending 1452 'User Info' ConVars to server (cl_spewuserinfoconvars to see)
================================
===  Wire revision: 2060     ===
=== Local Wire revision:2060 ===
================================
AdvDupeShared: Server Compression: false
Redownloading all lightmaps
prop at 2434 1893 -13264 missing modelname
entities/sent_dt/init.lua:16: Tried to use a NULL entity!
entities/sent_dt/init.lua:16: Tried to use a NULL entity!
entities/sent_dt/init.lua:16: Tried to use a NULL entity!
entities/sent_dt/init.lua:16: Tried to use a NULL entity!
entities/sent_dt/init.lua:16: Tried to use a NULL entity!
entities/sent_dt/init.lua:16: Tried to use a NULL entity!


[editline]02:08AM[/editline]

That’s when I commented out the take damage code.

prop at 2434 1893 -13264 missing modelname

Well apparently the model doesn’t exist. Try a different one. Find a prop in the spawn menu, put your mouse over it, right click it and, then click copy to clipboard. Then just paste it into your code.

Nope, tried a barrel,
entities/sent_dt/init.lua:16: Tried to use a NULL entity!

ent and Model are not defined in your function put
[lua]local ent = ents.Create(prop_physics) // this goes in function ENT:SpawnFunction(ply, tr)
local Model= ( “models/Items/item_item_crate.mdl” ) // this goes in function ENT:Initialize()[/lua]

so that your code should look like this
[lua]function ENT:SpawnFunction(ply, tr)
if not tr.Hit then return end
local ent = ents.Create(prop_physics)
local SpawnPos = tr.HitPos + tr.HitNormal*16
ent:SetPos(SpawnPos)
ent:SetVar(“Owner”,ply)
ent:Spawn()
ent:Activate()
return ent
end

function ENT:Initialize()
local model= ( “models/Items/item_item_crate.mdl” )
self.Entity:SetModel(model)
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity:SetUseType(SIMPLE_USE)
local phys = self.Entity:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
end
end

[/lua]

Well this is helpful, trying to learn lua when no one knows what the hell is going on.

Maybe if someone understands what I am doing, you could make a sent that works and I can look at it and see how to do it.

Maybe, just maybe, instead of assuming that WE’RE the ones who have the problem, try bursting your own introvertic bubble and think that, oh, maybe I’m the one who is having the problem. You said specifically that there was no error on the first post, directing every person trying to help you in the complete wrong direction. Later, youhad to FIND your old error which makes me know that you’re someone who downloads old, broken addons with flashy names and fill your addons to the brim, only to fail by filling your error console with useless errors pertaining to why the portal gun won’t work, etc. These people annoy me.

Wrong, I’m a smart browser, I know what most stuff is fake and what is not. I’m not assuming that anyone but me has the problem, I don’t know where the hell you got that from.

http://lua.diamondbuild.info/testsent_forsomeidiot.zip

…Thanks…

That allowed it to spawn and not have any errors, the only problems are that nothing works. What is a good way to set a props colour random?

[editline]07:56AM[/editline]

Could I possibly do it with a table?

[editline]09:01AM[/editline]

Also, before I go and make a new thread for such a small thing. What does the ; mean?