Hello :smile:,
I don't know what the problem is..
[code]
function ENT:Think()
self:NextThink(CurTime());
if self.ExistBattery == 0 then
local sequence = self:LookupSequence("disable")
self:ResetSequence(sequence)
elseif self.ExistBattery == 1 and self.PowerOn == 0 then
local sequence = self:LookupSequence("disable")
self:ResetSequence(sequence)
elseif self.ExistBattery == 2 and self.PowerOn == 1 then
local sequence = self:LookupSequence("power_on")
self:ResetSequence(sequence)
self:SetPlaybackRate(0.6)
self.ExistBattery = 3
timer.Simple( 2.4, function() self.ExistBattery = 4 end )
elseif self.ExistBattery == 4 and self.PowerOn == 1 then
local sequence = self:LookupSequence("idle")
self:ResetSequence(sequence)
elseif self.ExistBattery == 4 and self.PowerOn == 0 then
local sequence = self:LookupSequence("power_off")
self:ResetSequence(sequence)
self:SetPlaybackRate(0.6)
self.ExistBattery = 5
timer.Simple( 2.4, function() self.ExistBattery = 1 end )
end
return true;
end
function ENT:Use(v, caller)
if ( v:IsPlayer() ) && self.ExistBattery == 1 and self.PowerOn == 0 then
self.ExistBattery = 2
self.PowerOn = 1
elseif ( v:IsPlayer() ) && self.ExistBattery == 4 and self.PowerOn == 1 then
self.PowerOn = 0
end
end
[/code]
It's a "base_anim" Base Type, self.AutomaticFrameAdvance = true and self:SetUseType(SIMPLE_USE)
If you put a battery (Ent) on it and you use it, then it starts. If you use it again then it stops.
The problem: the power_on and power_off animations are not always playing correctly.. sometimes it playing it twice or it looks interrupted.
Any Ideas?
(sorry for my english)
I found the "problem".. I have just put self:SetCycle( 0 ) after self:ResetSequence(sequence), then it works :speechless:
Sorry, you need to Log In to post a reply to this thread.