- Code: Select all
dayLength = 86400 # number of seconds in a day
growth_Interval = 15 * dayLength # seconds between growth spurts for 15 day interval
[... break in code ...]
timeDelta = currentTime - lastGrowth
sizes = timeDelta / growth_Interval
if sizes > 0:
sdl["YP10LastTreeGrowth"] = (currentTime,) # Should be = lastGrowth + ( sizes * growth_Interval )
Looking at the code, I don't see any obvious reason for accelerated growth unless it gets a bogus value from PtGetDniTime() or somehow misreads the sdl value for YP10LastTreeGrowth. Multiple simultaneous calls from multiple threads (if that's possible) might result in the size possibly being bumped multiple times in one visit. Someone familiar with the overall code architecture would have to determine if that is even possible. A more accurate calculation could be done by computing the absolute size based on the time since the first visit rather than by computing an incremental size. With an absolute calculation, spurious values retrieved once would be corrected on the next visit.
- Code: Select all
currentTime = PtGetDniTime()
treeBaseline = sdl["YP10FirstTreeVisit"]
if treeBaseLine == 0;
treeBaseLine = currentTime
sdl["YP10FirstTreeVisit"] = treeBaseLine
dayLength = 86400 # number of seconds in a day
growth_Interval = 15 * dayLength # seconds between growth spurts for 15 day interval
absoluteTreeSize = 1 + ( currentTime - treeBaseLine ) / growth_Interval
return absoluteTreeSize
Please pardon any syntax errors since I am not well-versed in Python. It has been a few years since I dabbled with it.
David Tierce
Edit: fixed incomplete line for sdl initialization on first visit