It's a struggle to explain the issue. It works fine when i put in one entity to the cooker but when I have two cookers down give them one recipe each only the cooker that i last put a recipe into will spawn out bread.
Basically the second drug recipe overwrites the last one so it can only spawn one at a time. I can post code if it's not clear enough.
Mate, we wont be able to do ANYTHING if you dont show us some code. Just like in your last thread already.
Okay my bad, Here:
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
end
function ENT:StartTouch(ent)
if ent:GetClass() == "morphine_uncooked" and self.isBaking == false then
ent:Remove()
self.isBaking= true
self:startCooking()
end
end
function ENT:startCooking()
timer.Create("waitThenRemove", 5, 1, function()
local morphine = ents.Create("morphine_cooked")
morphine:SetPos(self:GetPos() + Vector(0,15,0))
morphine:Spawn()
self.isBaking = false
end)
end
cl.init doesnt have anything else than drawmodel and similar goes for shared.
timer.Create("waitThenRemove", 5, 1, function()
you're using the same timer name every time, so they overwrite each other, you can use
Entity/GetCreationID to get an entity identifier
I think you mean Entity/EntIndex.
Make sure you check if the entity is valid inside the timer before using it again - it could have been deleted in that time.
Rather than using timers, you'll probably have a better time if you use the entity's think hook. (As a bonus this will also let you show a progress bar on the clientside)
There's a nice example on how to do this on The Wiki
You sure about that? That gets called 60 times a second and is apparently bad to use from what Code Blue said.
Don't you think that's kinda unnecessary? It's just a cooking script after all. He'd just break his head trying to figure out the concept at an early stage of his learning process...
Your entity's think hook is called whether you use it or not and adding an if statement is hardly going to affect performance.
I think you're being a bit patronising. Checking if one number is bigger than another number isn't a very complicated concept.
It's also, imo, not unnecessary. Stray timers are a great source of problems and asynchronous code is always difficult to debug.
Sorry, you need to Log In to post a reply to this thread.