Setting up scripted entities in gmod...

Hey everyone!

So I ran into a problem a while back and I could use some help… How do you get a scripted entity to show up in the spawn menu in Gmod? I can make scripts that work nicely, but I’d like to be able to make spawnable entities. There doesn’t seem to be much documentation on the gmod wiki, last time I looked at least, and I was wondering if anyone can show me what code you need to make a base SENT that will show up in the “Entities” tab in gmod.

Thanks very much for your help!

EDIT: I’ve seen a couple guides on how to do it, but they seem to be designed for gmod 12 and below, the code does not work in GM13 and above…

Init.lua
Shared.lua
cl_init.lua

all go into lua/entities/example_entity

e.g.
brought to u by ricky

shared.lua
[lua]
ENT.Type = “anim”
ENT.Base = “base_gmodentity”

ENT.PrintName = “Sphere”
ENT.Author = “Ricky + Keosan”
ENT.Contact = “Don’t”
ENT.Purpose = “Exemplar material”
ENT.Instructions = “Use with care. Always handle with gloves.”

function ENT:Think()

for k,v in pairs(ents.FindInSphere(self:GetPos(), 50)) do
		if v:IsPlayer() then
			Dissolveit(v:LocalPlayer())
			end
end

end
[/lua]

init.lua

[lua]
AddCSLuaFile( “cl_init.lua” ) – Make sure clientside
AddCSLuaFile( “shared.lua” ) – and shared scripts are sent.

include(‘shared.lua’)

function ENT:Initialize()

	self:SetModel("models/props_junk/watermelon01.mdl")
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)
	self.Name = "Sphere"

	local phys = self:GetPhysicsObject()
	if phys:IsValid() then
		phys:Wake()
	end
end

function ENT:Use(activator,caller)

end

local ply = LocalPlayer()
function Dissolveit(ply)
local d = DamageInfo()
d:SetDamage(ply:Health())
d:SetAttacker(self)
d:SetDamageType(DMG_DISSOLVE)
ply:TakeDamageInfo(d)

end
[/lua]

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

function ENT:Draw()
self:DrawModel()
render.SetColorMaterial()
render.DrawSphere(self:GetPos(), 50,50,50, Color(0,175,175,100))

end
[/lua]

That still works? I tried that very same code before and it did not show up in my Q menu.

[editline]12th September 2016[/editline]

So I added:


ENT.Spawnable       = true
ENT.Category        = "Fun+Games"

To shared.lua And it works! Thanks! <3

Thanks you actually helped me. My entity is tied to a swep so i really only needed it to spawn upon secondary click but now it shows in the Q menu!