Hello forum members,
I’ve been trying to make a simple enemy framework. It works fine, but there’s this piece of code that I have to copy and paste all the time for cooldowns and it gets annoying to look at.
-- FSM; actually easier; can make statuses classes if you want to for better functionality if self._status == ENUM_STATUSES.Idle and not self.Calculating then self:__GetPath() self.Calculating = true delay(self.Smartness, function() self.Calculating = false end) end
elseif DistanceFromTarget < MOVE_WAY_DIST and not self.Attacking then -- close enough to damage self.TargetHum.Health -= self.Strength self.Attacking = true delay(self.Smartness, function() self.Attacking = false end) end
I’m not sure what they are called (debounces??) but they just seem to clutter my code. What can I do to replace this piece of code? Please leave below alternatives. Thanks for reading.