tl;dr: Can you change an unrelated variable inside another class?
Anyway, in my game, I want Characters to be in different locations at different times of the day. But I want there to be a sort of weighted system, as well. Person A isn't ALWAYS in the Bathroom in the morning, for example. But when she IS in the bathroom, she isn't anywhere else, if that makes sense.
That is easy enough to call once or twice with
Code: Select all
$ d20 = renpy.random.randInt (1,20)
if d20 > 10:
$ aLoc = "bathroom"
else:
$ aLoc = "somewhere else"
That is further compounded by time. I am using a class I saw here a while ago for time/date stuff.
Code: Select all
class gameTime:
gamePeriods = ("Early Morning","Morning","Late Morning","Afternoon","Midday","Evening","Night","Late Night")
def __init__(self):
self.now = 0
self.hours = 12
self.day = 1
self.periodCount = 0
self.timeSlept = 0
def tAdvance(self, n=1):
self.hours += n
self.periodCount += n
if self.hours >= 24:
self.hours -= 24
self.day += 1
day = self.day
while self.periodCount >= 3:
self.advance()
self.periodCount -= 3
def advance(self, n=1):
self.now += n
self.update()
def sleepMorning(self):
self.timeSlept = 1
self.tAdvance()
while self.hours != 6:
self.tAdvance()
self.timeSlept += 1
def hoursSlept(self):
return self.timeSlept
def period(self):
return gameTime.gamePeriods[self.now % len(gameTime.gamePeriods)]
def update(self):
if self.now >= len(gameTime.gamePeriods):
self.now -= 8
def date(self):
return str(self.day)
def getHours(self):
return str(self.hours)
def tSet(self, n=1):
self.timeSlept = 1
while self.hours != n:
self.tAdvance()
self.timeSlept +=1
Code: Select all
default aLoc = "bathroom"
class gameTime:
(...rest of the time class)
def update(self):
aLoc = "kitchen"
if self.now >= len(gameTime.gamePeriods):
self.now -= 8
(... rest of the time class)
label start:
$ g_time = gameTime()
$g_time.tAdvance(12)
a "I am in the [aLoc]!"
I'm also trying to figure out a more elegant way of dealing with the weighted nature of the character's schedules. instead of using renpy.random.randInt for everything.
Does anyone have any input? Or maybe push me in the right direction? Right place to look and all that?
Thank you so much!
Good vibes out,
EchoEcho