Jump to content

FPSPlayer.lua script bug


Recommended Posts

I noticed severall bugs in the FPSPlayer.lua script but forgot to report it.

 

In all cases the 'self.' keyword is forgotten. The following functions should be replaced.

 

--Return whether the player is crouching
function Script:IsAlive()
   return self.alive and 1 or 0
end

--TakeDamage
function Script:TakeDamage(damage)

   --Decrease health
   self.health = self.health - damage;

   --Call OnHit output
   self:OnHit()

   --If health lower or equal to zero, the player is dead
   if self.health <= 0 then
       self.alive = false
       --Call the OnDead output
       self:OnDead()
   end
end

--Increase health
function Script:ReceiveHealth(healthPoints)--in
   --Increase health
   self.health = self.health + healthPoints;

   --Health can not be more then maximum health
   if self.health > self.maxHealth then
       self.health = self.maxHealth
   end

   --Call Health received output
   self.component:CallOutputs("HealthReceived")
end


--when health is zero or lower, an output call is made
function Script:OnDead()--out
   --Extra check to make sure that the player is no longer alive
   if not(self:IsAlive()) then
       self.component:CallOutputs("Ondead")
   end
end

 

FPSPlayer.lua

Link to comment
Share on other sites

  • 2 weeks later...

Thank you. This doesn't affect the behavior, because no one uses more than one FPS script, but it is a mistake in design. Will be uploaded.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...