first of all, i'm new programming, sorry in advance :p
i'm having absolute nightmare trying infinite loop stay infinite...
the loop (which run on seperate thread) runs expected random amount of time, stops no errors.
it might run 5 minutes or 5 hours, stop... program doesn't freeze or crash, literally loop stops.
please on amazing, killing me.
# textwars # regenthread.py # module regenerate players health , magika on time # py lib import threading, time, datetime # textwars sub-pckg import db.dbfuncs db # textwars main import appfuncs import statsbar def regen(): next_call = time.time() player = appfuncs.current_player while 1: # print exact date , time admin use ensure thread # not drifting. comment out when not in use print datetime.datetime.now() # current player stats db stats = db.getrow(player) time.sleep(0.25) # var used ensure player health never exceeds max health. # max_health minus regen amount almost_health = stats[11] - 0.07 # if player isn't in battle, run regen if appfuncs.in_event == false: time.sleep(0.25) if stats[4] < almost_health: stats[4] += 0.07 elif stats[4] >= almost_health: stats[4] = stats[11] time.sleep(0.25) # save game if stats changed db.savegame(stats[0], stats[3], stats[4], stats[5], stats[6], stats[7], stats[8], stats[9], stats[10], stats[11], stats[12], stats[13], stats[14]) time.sleep(0.25) # update stats bar statsbar.statsbar() # wait 2 secs next_call = next_call + 2 time.sleep(next_call - time.time()) # call thread module def call(): thread = threading.thread(target=regen) thread.setdaemon(true) thread.start()
Comments
Post a Comment