Registering Ent to be able to use on Ents.Create

I created an entity in my gamemode named itemprop, and I was wondering why I can’t just ents.Create(‘itemprop’)

Is there a way to register it or something?

It should work, if it says that itemprop isn’t a valid entity type then there is an error in the entity’s script.

kk ill see whats wrong. How would I go about debugging the entity script :confused:

Simple, when you load up a map look in the console, there will be a lua error about your entity.

Nope, no error… here I will post the entity coding…

init.lua
[LUA]
AddCSLuaFile(“cl_init.lua”)
AddCSLuaFile(“shared.lua”)
include(“shared.lua”)

function ENT:Initialize()
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.CanUse = true
local phys = self.Entity:GetPhysicsObject()

if phys and phys:IsValid() then phys:Wake() end

self.damage = 10

end

function ENT:OnTakeDamage(dmg)
self.damage = self.damage - dmg:GetDamage()

if (self.damage <= 0) then
	local effectdata = EffectData()
	effectdata:SetOrigin(self.Entity:GetPos())
	effectdata:SetMagnitude(2)
	effectdata:SetScale(2)
	effectdata:SetRadius(3)
	util.Effect("Sparks", effectdata)
	self.Entity:Remove()
end

end

function ENT:Use(activator,caller)
if not self.CanUse then return false end
local Owner = self:GetNWEntity(“owning_ent”)

end

function ENT:OnRemove()
local ply = self.Entity:GetNWEntity(“owning_ent”)
if not ValidEntity(ply) then return end
end
[/LUA]

cl_init.lua
[LUA]
include(“shared.lua”)

function ENT:Initialize()
end

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

function ENT:Think()
end
[/LUA]

shared.lua
[LUA]
ENT.Type = “anim”
ENT.Base = “base_gmodentity”
ENT.PrintName = “Item Prop”
ENT.Author = “Dorfy”
ENT.Spawnable = false
ENT.AdminSpawnable = false
[/LUA]

Have you placed your entity in lua/entities/itemprop/ ?

yes, I have.

ERROR: attempted to create an unknown entity type

It doesn’t have a model.

Hm, it still shouldn’t screw it up because i set the model before i spawn it. Kinda like, create it set the model etc.

If it’s for a gamemode, the entity goes in here:

gamemodes/yourgamemode/entities/entities/yourentity

Thanks, you fixed it :P. Never really did any work with Entities so this was a big help. xD