Add an example to documentation.
This commit is contained in:
parent
53f307e8e3
commit
189124c751
1 changed files with 13 additions and 0 deletions
|
|
@ -34,6 +34,19 @@ db_attribute parameter.
|
||||||
@lazy_property
|
@lazy_property
|
||||||
def cooldowns(self):
|
def cooldowns(self):
|
||||||
return CooldownHandler(self, db_attribute="cooldowns")
|
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
|
import math
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue