luagarrys-mod

Can't make an entity in gmod


I'm mkaing an addon for Garry's Mod, but inorder for it to work, I must spawn an entity first, which is not working for me. I followed numerous tutorials on how to create an entity and spawn it and I can't even create it. Here is the tutorial I am following now: https://www.youtube.com/watch?v=uE5A4AwwIK8 This tutorial is made by Code Blue and he has made lots of very high quality addons and yet it still doesn't work, there are no lua errors and it doesn't even show up in the entity list in the 'q' menu.

My code is for the cl_init.lua file is below:

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

Next is the init.lua file:

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

function ENT:Initialize()

    self:SetModel( 'models/props_lab/monitor01a.mdl' )
    self:PhysicsInit(SOLID_VPHYSICS)
    self:SetMoveType(MOVETYPE_VPHYSICS)
    self:SetSolid(SOLID_VPHYSICS)
    self:SetUseType(SIMPLE_USE)

    local phys = self:GetPhysicsObject()

    if phys:Invalid() then
        phys:Wake()
    end
end

Last is the shared.lua file:

NT.Type = 'anim'
ENT.Base = 'base_gmodentity'

ENT.PrintName = 'Computer'
ENT.Spawnable = true

As far as I can tell, this is the same as what code blue did, but with a different model and print name.


Solution

  • Your problem is in the shared.lua as well as the init.lua file.
    You need to make sure you're capitalizing all of the letters. Here's what you messed up as far as I can tell:

    NT.Type = 'anim'
    if phys:Invalid() then