A question involving stat variables and changing backgrounds

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
SleepKirby
Veteran
Posts: 255
Joined: Mon Aug 09, 2010 10:02 pm
Projects: Eastern Starlight Romance, Touhou Mecha
Organization: Dai-Sukima Dan
Location: California, USA
Contact:

Re: A question involving stat variables and changing backgro

#16 Post by SleepKirby »

You're doing it like this, right? (All the repetition is the disappointing thing I was talking about in my previous post. See, when disposition.value changes, dispositionValue doesn't change with it unless you use another = statement.)

Code: Select all

label start:
    
    "Testing..."
    
    $ dispositionValue = disposition.value
    "%(dispositionValue)d"
    
    $ disposition.up(10)
    
    $ dispositionValue = disposition.value
    "%(dispositionValue)d"
    
    $ disposition.up(-30)
    
    $ dispositionValue = disposition.value
    "%(dispositionValue)d"
    
    $ disposition.up(100)
    
    $ dispositionValue = disposition.value
    "%(dispositionValue)d"
    
    scene bg opening

ProxyPawaa
Newbie
Posts: 23
Joined: Sun Jan 16, 2011 5:43 pm
Contact:

Re: A question involving stat variables and changing backgro

#17 Post by ProxyPawaa »

Thanks for clearing that up! The test works now, thanks a bunch man. ^_^ I'll come back tomorrow if I have problems with that condition switch thing. But... I figure I can just use if statements on that to get it to work, pair them together.

Now that you mention it... gah. Repeating that after every choice is something I wanna avoid. Since... condition switch won't work by asking it to read the plain value right? I'm going to try and place that within the condition switch so that it is always updating it. Maybe.

User avatar
SleepKirby
Veteran
Posts: 255
Joined: Mon Aug 09, 2010 10:02 pm
Projects: Eastern Starlight Romance, Touhou Mecha
Organization: Dai-Sukima Dan
Location: California, USA
Contact:

Re: A question involving stat variables and changing backgro

#18 Post by SleepKirby »

Cool, glad to hear it worked!
I guess in my game, I don't really have to display the values or variables very often at all (outside of testing that is) - so I didn't consider that inconvenience with $d. Hope it doesn't get in the way too much in your game (if it does though, then there are probably better approaches which I'm not thinking of).

Anyway, from the documentation's ConditionSwitch example, it looks like ConditionSwitch can use Python expressions. So my guess, at least, is that using disposition.value directly in there should work (without using the dummy variable dispositionValue).

ProxyPawaa
Newbie
Posts: 23
Joined: Sun Jan 16, 2011 5:43 pm
Contact:

Re: A question involving stat variables and changing backgro

#19 Post by ProxyPawaa »

Okay, question. Provided I already have DPV set to know the value that it needs to know...

Code: Select all

    image bg waterfront = ConditionSwitch(
        "?", "waterfront_day.jpg",
        "?", "waterfront_night.jpg",
        )
how would I go about asking where the ?'s are, to check and see if the value is higher than something, or lower than something?

also, how would I go about persay, asking to see if they're between two certain values? Like...

if dpv < 15
if dpv > -15
and
if dpv between -15 and 15....

how would I go about that?

Megaman Z
Miko-Class Veteran
Posts: 829
Joined: Sun Feb 20, 2005 8:45 pm
Projects: NaNoRenO 2016, Ren'Py tutorial series
Location: USA
Contact:

Re: A question involving stat variables and changing backgro

#20 Post by Megaman Z »

The documentation wrote:...On each interaction, it evaluates the conditions in order to find the first that is true, and then displays that displayable. It is an error for no condition to be true.
Go in ascending or descending order. For example:

Code: Select all

    image whatever conditionswitch(
        "dpv > 15", "imga.png",
        "dpv > -15", "imgb.png",
        "true", "imgc.png")
so if dpv is above 15, imga.png is used, even though dpv is also above -15, because the first check that passes is dpv > 15.
if dpv is 0, imgb.png is used, because it fails the first check (dpv > 15) but passes the second check.
if dpv is -200, it fails all the explicit checks, so imgc.png is used, because "true" is always true.

and I really should start reading up on some of these myself.
~Kitsune Zeta

Post Reply

Who is online

Users browsing this forum: No registered users