Timed player regeneration
Posted: Tue Dec 30, 2014 11:50 pm
I'm trying to develop a way such that certain players regenerate health periodically. The time and amount of health varies by player. This is my first solution, and was wondering if anyone had a better idea.
Syntax: Select all
def regenLoop(tick=0):
for players in PlayerGenerator():
myPlayer = playerDictionary[players]
if myPlayer['regen'] > 0:
if tick >= myPlayer['regentime'] and tick % myPlayer['regentime'] == 0:
PlayerEntity(index_from_playerinfo(players)).health += myPlayer['regen']
regenTimer = TickRepeat(regenLoop, tick+1)
regenTimer.start(1,1)
regenLoop()