I'm going crazy, I'm trying to make a simple entity and nothing seems to be working. If I spawn it with ent_create (because It's not in the spawn menu) it says: Error creating 'crate_uncommon' (Make sure the file is AddCSLuaFile'd and there aren't any errors!) and it is invisible. It manages to spam the console with "loltest", which is better because originally it didn't even do that.
[url]http://cloud-4.steamusercontent.com/ugc/544142572198835682/01ECF6E353885F72A59260F7A491751C3A7A2F45/[/url]
Folder/File Format:
testaddon/lua/entities/crate_uncommon/
cl_uncommon.lua
[CODE]include("sh_uncommon.lua")
function ENT:Initialize()
end
function ENT:Draw()
self:DrawModel()
end[/CODE]
init.lua (Can I rename this to something else somehow?)
[CODE]AddCSLuaFile("cl_uncommon.lua")
AddCSLuaFile("sh_uncommon.lua")
include("sh_uncommon.lua")
function ENT:Initialize()
self:SetModel("models/props_junk/wood_crate001a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
local phys = self:GetPhysicsObject()
if phys and phys:IsValid() then
phys:EnableMotion(true)
phys:Wake()
end
end
function ENT:Use(activator, caller, uType, value)
if activator:IsPlayer() then
self:Remove()
self:Unbox(activator)
end
end
function ENT:Think()
print("loltest") -- This actually prints loltest in my console on singleplayer, which is weird because at one point it actually didn't work AT ALL.
end
function ENT:Unbox(ply)
self:EmitSound('npc/combine_soldier/zipline_clip1.wav', 100)
end
function ENT:OnRemove()
end
[/CODE]
sh_uncommon.lua
[CODE]ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Uncommon Crate"
ENT.Author = "Person"
ENT.Spawnable = true
ENT.AdminSpawnable = false
ENT.Category = "Test"
ENT.Contact = ""
ENT.Purpose = ""
ENT.Instructions = ""
ENT.Author = "Person"[/CODE]
Any help is seriously appreciated, thanks!
Rename cl_uncommun.lua to cl_init.lua
Rename sh_uncommon.lua to shared.lua
Don't forget to change the value of AddCSLuaFile/include to match file name.
I think you shouldn't change name of file because when Garry's Mod will search entities folder, it will look for a file or folder, if it look into a folder, the system will search for cl_init.lua/init.lua/shared.lua and if no one of file is matching these name, it will be ignored.
Is this listed somewhere so I can study the file structures?
Thanks, issue solved.
[QUOTE=makermod1;47000886]Is this listed somewhere so I can study the file structures?
Thanks, issue solved.[/QUOTE]
Please ignore about file structures. It's a mess to find it for others types and sometimes complicated.
What I can say is you could take a look onto these when you need: wiki.garrysmod.com or maurits.tv (old).
Sorry, you need to Log In to post a reply to this thread.