Renpy age variable adjustments

Shadow2007

Member
Aug 9, 2020
268
291
I'm hoping someone might be able to help me with a script issue I cant seem to find how to do....

I have a need to set the people age according to the players want's working but the issue is adding or subtracting to that....

At the start of my script (game) I need to take away 2 years and 4 years from the inputted variable of what the play puts in.

I have tried things I found that are meant to work but never getting it to work....

I need the corrected ages at line 112 and 116 where I have (...)th, also at line 100 and 102 where its (...) right now.

As you can see my VN is going to rely on the plays inputs very much for the dialog to work correctly.

Thanks if anyone can help with this....


You don't have permission to view the spoiler content. Log in or register now.

View attachment script.rpy
 

Deleted member 2282952

Developing I SCREAM
Game Developer
May 1, 2020
416
870
If you define as:
character_data = {
"Character1": {
"age": 27,
}
}
Then you can just call the variable from anywhere as:

$ character_data["Character1"]["age"] += 2 # or -= or whatever you need.

Depends on how you structure your code, but it is as simple as adding that line of code, or adjusting how you store things
 
  • Like
Reactions: Shadow2007

Shadow2007

Member
Aug 9, 2020
268
291
If you define as:
character_data = {
"Character1": {
"age": 27,
}
}
Then you can just call the variable from anywhere as:

$ character_data["Character1"]["age"] += 2 # or -= or whatever you need.

Depends on how you structure your code, but it is as simple as adding that line of code, or adjusting how you store things
How does that look code wise?
is
define as: character_data = ["Character1": ["age": 27,]] right?

I have :
define d = Character("[dg]", color="#8b13d1")
define d_age = Character("[dage]", color="#8b13d1")

which is the main character I need to alter they age setting....
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,236
It should be just $ Zeil.d_age += 2
Not sure at all that it's what he want.

As I read it, when he say that "at the start of [his] script (game) [he] need to take away 2 years and 4 years from the inputted variable of what the play puts in", he mean something like "blabla [Zeil.d_age - 2] blabla".
Therefore the class need a [icode]d_age2
and d_age4 properties:
Python:
init python:
    class Whatever( renpy.python.RevertableObject ):
        [...]
        @property
        def d_age2( self ):
            return self.d_age - 2

        @property
        def d_age4( self ):
            return self.d_age - 4
that he'll be able to directly use with text interpolation.