• Help with an entity
    4 replies, posted
I'm trying to make an entity and I was testing it with jsut the basics put in but it's not working. It doesn't even show up on the menu. I put it into lua/entities/test/ with the shared in the test folder, client in the client folder and server in the server folder. Server [code] AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') function ENT:Initialize() self:SetModel("models/props/cs_assault/moneypallet_washerdryer.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end end [/code] Client [code]include("shared.lua") function ENT:Initialize() end function ENT:Draw() self.Entity:DrawModel() end function ENT:Think() end [/code] Shared [code] ENT.Type = "anim" ENT.Base = "base_wire_entity" ENT.PrintName = "drug plant" ENT.Author = "moi" ENT.Contact = "none of your business" ENT.Purpose = "test" ENT.Instructions = "test" ENT.Spawnable = true ENT.AdminSpawnable = true [/code]
I think you have the locations of the Lua files wrong. You should have a file named cl_init.lua which contains all of your client code, a file called init.lua which contains all of your server code and a file called shared.lua which includes the shared code. All three of these should go in lua/entities/test/ in your case.
I put them where you said and restarted gmod. Still the same :( EDIT it shows up on the entity menu but I can't spawn it.
Your init.lua needs an ENT:SpawnFunction to tell it exactly what to do when you try to spawn one of these via the spawn menu. There's a nice standard one in the Wiki: [url]http://wiki.garrysmod.com/?title=ENT.SpawnFunction[/url] Just copy and paste into your init.
Thanks Johnny, I was having this exact problem, too. I'll try it out now.
Sorry, you need to Log In to post a reply to this thread.