[SOLVED] Values and Displaying Images Not Working

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.
Post Reply
Message
Author
User avatar
LewdEdits
Newbie
Posts: 6
Joined: Sat Apr 17, 2021 8:33 pm
Completed: 0
Projects: 1
Contact:

[SOLVED] Values and Displaying Images Not Working

#1 Post by LewdEdits »

The purpose of this code is to speed up, slow down and show the "Car" based on values. My problem is when I accelerate, it will switch between cars without any issue.

Speed 0 = Car_0
Speed 1 = Car_1
Speed 2 = Car_2
Speed 3 = Car_3

The issue is, the image stays on Car_3 when slowing down. Below is the code I'm using, any suggestions would help.
And if you have any questions, I will do my best to answer them.

Code: Select all

label CarSpeedSelect:
        "Start Moving" if CarMoveStart == True and CarSpeedValue == 0:
            $ CarSpeedValue += 1
            call CarImageShow
            jump CarSpeedSelect

        "Move Faster" if CarSpeedShow == True:
            $ CarSpeedValue += 1
            call CarImageShow
            jump CarSpeedSelect

        "Move Slower" if CarSlowShow == True:
            $ CarSpeedValue -= 1
            call CarImageShow
            jump CarSpeedSelect


label CarImageShow:

    if VehicleValueTracking == 5:
        if CarSpeedValue == 0:
            $ CarSpeedShow = False
            $ CarSlowShow = False
            screen Street
            show Car_0

        elif CarSpeedValue == 1:
            $ CarSpeedShow = True
            $ CarSlowShow = False
            screen Street
            show Car_1

        elif CarSpeedValue == 2:
            $ CarSpeedShow = True
            $ CarSlowShow = True
            screen Street
            show Car_2

        elif CarSpeedValue == 3:
            $ CarSpeedShow = False
            $ CarSlowShow = True
            screen Street
            show Car_3

      

    elif VehicleValueTracking == 6:
        if CarSpeedValue == 0:
            $ CarSpeedShow = False
            $ CarSlowShow = False
            screen Street
            show Bike_0

        elif CarSpeedValue == 3:
            $ CarSpeedShow = False
            $ CarSlowShow = True
            screen Street
            show Bike_1

        elif CarSpeedValue == 2:
            $ CarSpeedShow = True
            $ CarSlowShow = True
            screen Street
            show Bike_2

        elif CarSpeedValue == 1:
            $ CarSpeedShow = True
            $ CarSlowShow = False
            screen Street
            show Bike_3

    return
Last edited by LewdEdits on Mon Apr 19, 2021 11:17 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Values and Displaying Images Not Working

#2 Post by Ocelot »

Try to define Car_X images, so they wouldn't be in the same place on screen and check wgat happens. I am pretty positive that Car_2 is still displayed, as it should, just below Car_3, but I would like clarification, that this is indeed the problem.
< < insert Rick Cook quote here > >

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Values and Displaying Images Not Working

#3 Post by Imperf3kt »

A few years ago I was doing something similar for a card game that had the exact same issue.
In the end I found it better to use condition switch.
https://www.renpy.org/doc/html/displaya ... tionSwitch
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
LewdEdits
Newbie
Posts: 6
Joined: Sat Apr 17, 2021 8:33 pm
Completed: 0
Projects: 1
Contact:

Re: Values and Displaying Images Not Working

#4 Post by LewdEdits »

Ocelot wrote: Mon Apr 19, 2021 2:05 am Try to define Car_X images, so they wouldn't be in the same place on screen and check wgat happens. I am pretty positive that Car_2 is still displayed, as it should, just below Car_3, but I would like clarification, that this is indeed the problem.
Yup, that seems to have been the issue, I'm still getting the hang of coding. So now, the question I asked myself is why it was doing that from what I recalled, when you pulled up a new scene, it should remove everything and display the new background along with any image called.....

And that's when I realized I wasn't using the scene function, rather the screen function. I switched out "screen" for "scene" and it seems to have resolved my issue. Thank you for the suggestion!


Imperf3kt wrote: Mon Apr 19, 2021 4:26 am A few years ago I was doing something similar for a card game that had the exact same issue.
In the end I found it better to use condition switch.
https://www.renpy.org/doc/html/displaya ... tionSwitch
I'll have to look into this, it might simplify things out in the long run vs what I'm using now. Thank you for the suggestion.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]