CREATE YOUR AI CUM SLUT ON CANDY.AI TRY FOR FREE
x

Ren'Py characters at certain time and locations

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,131
3,195
Just a small problem

the lbt="" part it's not call the proper label it always call the last label storeclerks_closing_talk even though I set the time to 9 am I wonder if I can change the lbt to call

Python:
#storeclerk
    $ NPCS.append(NPC("storeclerk", "store", 9, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 10, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 11, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 12, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 13, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 14, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 15, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 16, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 17, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 18, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 19, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 20, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 21, lbt="storeclerks_closing_talk")
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,131
3,195
Just a small problem

the lbt="" part it's not call the proper label it always call the last label storeclerks_closing_talk even though I set the time to 9 am I wonder if I can change the lbt to call

Python:
#storeclerk
    $ NPCS.append(NPC("storeclerk", "store", 9, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 10, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 11, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 12, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 13, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 14, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 15, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 16, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 17, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 18, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 19, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 20, lbt="storeclerk_talk"))
    $ NPCS.append(NPC("storeclerk", "store", 21, lbt="storeclerks_closing_talk")
it works in different locations but not in same location
 

peterppp

Active Member
Mar 5, 2020
769
1,359
it works in different locations but not in same location
how do you select the npc object? it sounds like you are not selecting the npc object based on time and location, only on location and get the last npc added.

but why are you adding all those different npcs for every hour? unless each npc is a different clerk working 1 hour each, that's the wrong way to do it because you have several npc objects that are actually the same npc in the game.

you only need one npc for the clerk and in that class you define what the lbt is for different times
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,131
3,195
how do you select the npc object? it sounds like you are not selecting the npc object based on time and location, only on location and get the last npc added.

but why are you adding all those different npcs for every hour? unless each npc is a different clerk working 1 hour each, that's the wrong way to do it because you have several npc objects that are actually the same npc in the game.

you only need one npc for the clerk and in that class you define what the lbt is for different times
please read the main post

it's the same character for each hour if the hour pass the character will disappear that why there are more then one.
she there from 9am to 9pm store hour
hope this help you to understand
Python:
$ NPCS.append(NPC("storeclerk", "store", 9, lbt="storeclerk_talk"))
$ NPCS.append(NPC("character_name", "location", hour, label))
 

peterppp

Active Member
Mar 5, 2020
769
1,359
please read the main post

it's the same character for each hour if the hour pass the character will disappear that why there are more then one.
she there from 9am to 9pm store hour
hope this help you to understand
Python:
$ NPCS.append(NPC("storeclerk", "store", 9, lbt="storeclerk_talk"))
$ NPCS.append(NPC("character_name", "location", hour, label))
but you are adding a new npc object for every hour. so you have several npc objects for the same in-game character. that's not good object oriented programming and now you are having problems because of it

you didn't answer how you select the npc. i repeat:
how do you select the npc object? it sounds like you are not selecting the npc object based on time and location, only on location and get the last npc added.

also, not sure this works correctly: $ NPCS.append(NPC("storeclerk", "store", 9, lbt="storeclerk_talk")) since you dont add the parameter for minutes. writing it like this: $ NPCS.append(NPC("character_name", "location", hour, label) definitely looks wrong because you didn't include minutes, so label here would be minutes.
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,131
3,195
but you are adding a new npc object for every hour. so you have several npc objects for the same in-game character. that's not good object oriented programming and now you are having problems because of it

you didn't answer how you select the npc. i repeat:
how do you select the npc object? it sounds like you are not selecting the npc object based on time and location, only on location and get the last npc added.

also, not sure this works correctly: $ NPCS.append(NPC("storeclerk", "store", 9, lbt="storeclerk_talk")) since you dont add the parameter for minutes. writing it like this: $ NPCS.append(NPC("character_name", "location", hour, label) definitely looks wrong because you didn't include minutes, so label here would be minutes.
I have removed minutes because I like the characters to stay for an hour the code is working fine but call each label not working
 

peterppp

Active Member
Mar 5, 2020
769
1,359
that's only I know to do it if there was another was then show me
i'm asking about the code. what is your code to select which npc to show?
this is the code you have in your opening post. is this the one you're using?
Python:
screen charcater_screen():

    for q in NPCS:
        if q.location == location:

            imagebutton:
                idle q.avatar
                hover q.avatar
                focus_mask True
                action Call(q.lbt)
in that case, you must also check that the time is the same. something like
if q.location == location && q.hours == hours:
 
  • Like
Reactions: rayminator

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,131
3,195
i'm asking about the code. what is your code to select which npc to show?
this is the code you have in your opening post. is this the one you're using?
Python:
screen charcater_screen():

    for q in NPCS:
        if q.location == location:

            imagebutton:
                idle q.avatar
                hover q.avatar
                focus_mask True
                action Call(q.lbt)
in that case, you must also check that the time is the same. something like
if q.location == location && q.hours == hours:
yes that the code

if q.location == location && q.hours == hours:
had to change to if q.location == location and q.hours == hours:

it worked fine
 
  • Like
Reactions: peterppp

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,131
3,195
Python:
@property
def avatar(self):
    avtr = "images/avatar/{}_{}_{}_{}.png".format(self.name, str(hours), str(minutes), location)
is there way to give a folder for each character?

Python:
@property
def avatar(self):
avtr = "images/avatar/{folder}/{name}_{hour}_{minute}_{location}.png".format(self.name, str(hours), str(minutes), location)
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,131
3,195
is there way to give a folder for each character?

Python:
@property
def avatar(self):
avtr = "images/avatar/{folder}/{name}_{hour}_{minute}_{location}.png".format(self.name, str(hours), str(minutes), location)
I have figure it out had to change

Python:
class NPC(object):
        def __init__(self, name, location, hours, minutes, lbt=""):
            self.name = name
            self.location = location
            self.hours = hours
            self.minutes = minutes
            self.lbt = lbt



        #If you remove the minutes remove one of the {} and remove str(minutes),
        @property
        def avatar(self):
            avtr = "images/avatar/{}_{}_{}_{}.png".format(self.name, str(hours), str(minutes), location)



            if renpy.loadable(avtr):
                return avtr
            else:
                return "images/avatar/empty.png"
to this

Python:
class NPC(object):
        def __init__(self, name, nicename, location, hours, lbt=""):
            self.name = name
            self.nicename = nicename
            self.location = location
            self.hours = hours
            self.lbt = lbt


        @property
        def avatar(self):
            avtr = "images/avatar/{}/{}_{}_{}.png".format(self.name, self.nicename, str(hours), location)
           
       
            if renpy.loadable(avtr):
                return avtr
            else:
                return "images/avatar/empty.png"
change this

Python:
label InitialiseVariables:
    #If you remove minutes just remove the minutes out
    $ NPCS.append(NPC("mom", "livingroom", 12, 0, lbt="test"))
    #$ NPCS.append(NPC("character_name", "location", hour, minutes, lbt="label"))
to this

Python:
label InitialiseVariables:
    #If you remove minutes just remove the minutes out
    $ NPCS.append(NPC("mom", "mom", "livingroom", 12, 0, lbt="test"))
    #$ NPCS.append(NPC("character_name", "folders name", location", hour, minutes, lbt="label"))
updated the main post
 
Last edited:

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,131
3,195
just a small question

Python:
@property
    def avatar(self):     
        #If you remove the minutes remove one of the {} and remove str(minutes),
        avtr = "images/avatar/{}/{}_{}_{}_{}.png".format(self.name, self.nicename, str(hours), str(minutes), location)
if I want to add in pregnancy to this

Python:
@property
    def avatar(self):     
        #If you remove the minutes remove one of the {} and remove str(minutes),        
        if pregnant == True:
            avtr = "images/avatar/{}/{}_{}_{}_{}_pregnant.png".format(self.name, self.nicename, str(hours), str(minutes), location)
        else:
            avtr = "images/avatar/{}/{}_{}_{}_{}.png".format(self.name, self.nicename, str(hours), str(minutes), location)
will it work
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,131
3,195
just a small question

Python:
@property
    def avatar(self):    
        #If you remove the minutes remove one of the {} and remove str(minutes),
        avtr = "images/avatar/{}/{}_{}_{}_{}.png".format(self.name, self.nicename, str(hours), str(minutes), location)
if I want to add in pregnancy to this

Python:
@property
    def avatar(self):    
        #If you remove the minutes remove one of the {} and remove str(minutes),       
        if pregnant == True:
            avtr = "images/avatar/{}/{}_{}_{}_{}_pregnant.png".format(self.name, self.nicename, str(hours), str(minutes), location)
        else:
            avtr = "images/avatar/{}/{}_{}_{}_{}.png".format(self.name, self.nicename, str(hours), str(minutes), location)
will it work
no it will not work