From 5ce63ae52be8918bfcac5da7bb9d10b5fac7f19f Mon Sep 17 00:00:00 2001 From: Owllex Date: Wed, 24 Nov 2021 13:39:58 -0800 Subject: [PATCH] Add an example to documentation. --- evennia/contrib/cooldowns.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/evennia/contrib/cooldowns.py b/evennia/contrib/cooldowns.py index cb120b54b4..44d59eeab9 100644 --- a/evennia/contrib/cooldowns.py +++ b/evennia/contrib/cooldowns.py @@ -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