Need help with some coding

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
WizzyGameMaster
Regular
Posts: 40
Joined: Tue Mar 03, 2015 11:03 pm
Projects: Misfits. Summon!
Deviantart: WizzyGameMaster
Contact:

Need help with some coding

#1 Post by WizzyGameMaster »

Alright, so in a project of mine, MIsfits, there's an option to go back to a scene early in the game and make different choices.
My issue is: I want to have a scene play when you've gone back to the beginning and play through some of the early scenes, but not when you first play through it.

That probably makes no sense...

So we have the "start" of the game. Then gameplay goes as normal up until you reach scene "B." "B" then will give you a choice to continue the path or return to a scene that happens right after "start."
I want to make scene "A" show up sometime after the "start", but not on the first time through.
I want it to appear only after you see scene "B" and choose to return to an earlier point in the game.

What I want to know is, just how would I code that into the script and have it actually work?
I'm not asking for anything specific, just a basic idea of how I'd have to do it to make it work. Like a template or reference.

If it's not possible then it's no big deal, I'll just simply remove that extra route from game. But if I can, I'd like to include it.
I should probably also mention that this is my first time using Ren'Py, so I may not actually know much of what I'm doing.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Need help with some coding

#2 Post by trooper6 »

Some people will point you to persistent variables (http://www.renpy.org/doc/html/persistent.html)
But I think you could probably just use a regular variable.

Something like:

Code: Select all

label start:
    $ show_scene_a = False

    "Here is the start scene."
    "Lots of stuff happens."

label scene_0:
    "Here were are in another scene."
    "More stuff happens"

label scene_a:
    if show_scene_a == False:
        jump scene_b

    "You won't see this on the first play through because our variable is false."
    "But you will see it if you come back after scene_b, because then the variable is true."

label scene_b:
    "Whoah! It turns out I have time control abilities!"
    menu:
        "Will you go back in time to scene_0?"
        "Yes":
            $show_scene_a = True
            jump scene_0
        "No":
            $show_scene_a = True

    "If you don't jump back, the story continues on here..."
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
WizzyGameMaster
Regular
Posts: 40
Joined: Tue Mar 03, 2015 11:03 pm
Projects: Misfits. Summon!
Deviantart: WizzyGameMaster
Contact:

Re: Need help with some coding

#3 Post by WizzyGameMaster »

trooper6 wrote:Some people will point you to persistent variables (http://www.renpy.org/doc/html/persistent.html)
But I think you could probably just use a regular variable.

Something like:

Code: Select all

label start:
    $ show_scene_a = False

    "Here is the start scene."
    "Lots of stuff happens."

label scene_0:
    "Here were are in another scene."
    "More stuff happens"

label scene_a:
    if show_scene_a == False:
        jump scene_b

    "You won't see this on the first play through because our variable is false."
    "But you will see it if you come back after scene_b, because then the variable is true."

label scene_b:
    "Whoah! It turns out I have time control abilities!"
    menu:
        "Will you go back in time to scene_0?"
        "Yes":
            $show_scene_a = True
            jump scene_0
        "No":
            $show_scene_a = True

    "If you don't jump back, the story continues on here..."
Thanks. I'll have to give this a try and hopefully I can make it work.
I'm still really new to this stuff, so let's hope i can get it to work. (Even though it means more work for me if it does work. But I've got too much time on my hands anyway.)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Rhapsy