Hello how do i define a Character class in renpy and then call this character in the text

darkshaw

Newbie
Jan 20, 2019
68
26
init python:
class Person:
def __init__(self, character, name, trust = 0, happiness = 0):
self.c = character
self.name = name
self.trust = trust
self.happiness = happiness

$ K = Person(Character("Kimura"), "Kimura")


"Lorem Ipsum [K] Lorem Ipsum. ".

How i make K work here?
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
5,101
7,488
Tried first thing but


" Lorem Ipsum [K.c]Lorem Ipsum".

View attachment 3885817


Python:
init python:
    class Person:
        def __init__(self, character, name, trust = 0, happiness = 0):
            self.c = character
            self.name = name
            self.trust = trust
            self.happiness = happiness
 
define e = Character("Eileen", what_color = "#ffffff")
     
label start:
    $ K = Person(Character("Kimura"), "Kimura")
    e "blabla [K.c]"
 

GNVE

Active Member
Jul 20, 2018
707
1,161
Because of everything explained in this thread ; what include the default ... also presented by Winterfire.
Sorry for the hijack. Just to check if I am applying the info in that post correctly: I have a few classes that only handle functions shared among classes (e.g. rounding down, rounding up, checking if conditions have been met etc.) these can be set as define right? I do not expect them to change. Or is there something I missed.
 
  • Like
Reactions: darkshaw

darkshaw

Newbie
Jan 20, 2019
68
26
Sorry for the hijack. Just to check if I am applying the info in that post correctly: I have a few classes that only handle functions shared among classes (e.g. rounding down, rounding up, checking if conditions have been met etc.) these can be set as define right? I do not expect them to change. Or is there something I missed.
do you have an example code to share? I don't know also. Think Define would be okay. From what i read but needs testing.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,486
15,381
[...] these can be set as define right? I do not expect them to change.
Strictly speaking, you are right. Anything that will be constant through the game should be declared with define. And classes that only have methods are constant.


But what bother me is the "do not expect them to change". If next year you discover that finally one have to change over time, it will still be defined, and you'll struggle to deal with it. At first the changes will not be saved, and you'll probably wonder what is happening. Then, to be save compatible you'll have to address Ren'Py's internal to make the class savable, because just changing the define into default will not be enough.

This said, it's just my thought, and a bit of insight I provide. I understand that your "expect" is more a way to say things, than your current thoughts.
 

GNVE

Active Member
Jul 20, 2018
707
1,161
Strictly speaking, you are right. Anything that will be constant through the game should be declared with define. And classes that only have methods are constant.


But what bother me is the "do not expect them to change". If next year you discover that finally one have to change over time, it will still be defined, and you'll struggle to deal with it. At first the changes will not be saved, and you'll probably wonder what is happening. Then, to be save compatible you'll have to address Ren'Py's internal to make the class savable, because just changing the define into default will not be enough.

This said, it's just my thought, and a bit of insight I provide. I understand that your "expect" is more a way to say things, than your current thoughts.
Hmm yeah... I doubt it but to be on the safe side it might be better to err on the side of caution :)