• Entity not registering the "use" function
    5 replies, posted
I have and entity created and i am getting this error when i spawn the entity. [ERROR] addons/ammo_vendingmachine/lua/entities/ammo_machine/init.lua:17: attempt to index global 'ENT' (a nil value)   1. unknown - addons/ammo_vendingmachine/lua/entities/ammo_machine/init.lua:17    2. Spawn - [C]:-1     3. SpawnFunction - gamemodes/base/entities/entities/base_entity/init.lua:70      4. Spawn_SENT - gamemodes/sandbox/gamemode/commands.lua:662       5. unknown - gamemodes/sandbox/gamemode/commands.lua:727        6. unknown - lua/includes/modules/concommand.lua:54 This is the Portion of the code that the error is referring to function ENT:Use(caller, activator) print("someone Used me :(") end What exactly is the issue with this function. I have more code above that function, basically i only have the ENT:Initalize() above that code and a local phys wake up and all the addfile code.
From the last thread, this is your whole code? AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") function ENT:Initialize() self:SetModel( "models/props_interiors/VendingMachineSoda01a.mdl" ) self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) self:SetUseType(SIMPLE_USE) local physics = self:GetPhysicsObject() if (physics:IsValid()) then physics:Wake() end function ENT:Use(caller, activator) print("someone Used me :(") end If so, you still haven't ended the Initialize function.
Can you post the whole code?
no that is not the whole code. i have fixed the ends and have the entity spawning now and in the q menu AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") function ENT:Initialize() self:SetModel( "models/props_interiors/VendingMachineSoda01a.mdl" ) self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) self:SetUseType(SIMPLE_USE) local physics = self:GetPhysicsObject() if (physics:IsValid()) then physics:Wake() end print("Entity has loaded?????") function ENT:Use(caller, activator) print("someone Used me :(") end end that is the whole file
Take your ENT:Use function out of the ENT:Initialize one.
Sorry for the noob error! Still trying to get the hang of formatting and certain basic things and i completely overlooked that!
Sorry, you need to Log In to post a reply to this thread.