Add an example to documentation.

This commit is contained in:
Owllex 2021-11-24 13:39:58 -08:00
parent 29896a82e8
commit 5ce63ae52b

View file

@ -34,6 +34,19 @@ db_attribute parameter.
@lazy_property
def cooldowns(self):
return CooldownHandler(self, db_attribute="cooldowns")
Example:
Assuming you've installed cooldowns on your Character typeclasses, you can
use a cooldown to limit how often you can perform a command:
class PowerAttack(Command):
def func(self):
if self.caller.cooldowns.ready("power attack"):
self.do_power_attack()
self.caller.cooldowns.set("power attack", 10)
else:
self.caller.msg("That's not ready yet!")
"""
import math