I can't access that variable outside of ENT:Initialize() and ENT:StartTouch(). I could make a THINK method but i think it's dumb to call for something 60 times a second when already have a timer made.
Could you give a specific example of what you're trying to accomplish? You can get any entity variable at any time if you have the entity object.
Sure take a look at source code
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_lab/crematorcase.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
end
self.isBaking = false
self.finishBakeTime = 0
getPos = self:GetPos()
end
function ENT:StartTouch(ent)
if ent:GetClass() == "morphine_uncooked" and self.isBaking == false then
ent:Remove()
self.isBaking= true
startCooking()
end
end
function startCooking()
timer.Create("waitThenRemove", 5, 1, function()
local morphine = ents.Create("morphine_cooked")
morphine:SetPos(getPos + Vector(0,15,0))
morphine:Spawn()
self.isBaking = false
end)
end
as you can see: self.isBaking is a boolean i cannot access because it's in a normal function and not a built in ENT:Function
Change startCooking to ENT:startCooking. You can call the method with self:startCooking()
OOHH thanks i did not think of that
Sorry, you need to Log In to post a reply to this thread.