renpy.random.choice repeating issuses [solved]

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
PoisionLullaby
Regular
Posts: 42
Joined: Wed Jan 10, 2018 9:11 pm
Projects: We're all human
Deviantart: PoisionLullaby
Contact:

renpy.random.choice repeating issuses [solved]

#1 Post by PoisionLullaby » Wed Jan 31, 2018 11:40 am

So let me start off by explaining what I'm intending to do. I'm using DSE and I'm trying to make it where if you decide to do "go outside" on the daily planner it will then randomly choose between two events. "Run into creature" and "Normal walk". On the normal walk I want it to randomize what the player see's so something like, "You see a dog on your walk.","You see a small flock of birds.","Your walk is peaceful.", ect. Here's what my code looks like.

Code: Select all


label go_outside:
    call expression renpy.random.choice(["run_into_creature", "normal_walk"])
    
label normal_walk:
    
    $ animal = renpy.random.choice(encounter)
    "You begin to walk down a small path in the forest. [animal]"
    $ stat += 10
    
    return

Then on the run into a creature label I'd like to give the player a choice between something. Here's that code.

Code: Select all

label run_into_creature:

    "You see a horse galloping down the road."
    
      menu:
          "attempt to stop it":
          $ stat +=10
          
          "avoid it":
          $ stat -=10
          
      return
      
and before the script I have encounter defined like this as told by someone else.

Code: Select all

define encounter = ["You see a dog on your walk.", "You see a small flock of birds.", "Your walk is peaceful."]
My issue is that when I choose to "go outside" It will say "You begin to walk down a small path in the forest. You see a dog on your walk.", then "You begin to walk down a small path in the forest. You see a small flock of birds." before proceeding. Sometimes it will do something similar but instead of repenting it says "You begin to walk down a small path in the forest. You see a dog on your walk.", then "You see a horse galloping down the road." (choices on screen) "attempt to stop it", "avoid it". I have no clue why. Any help is appreciated and I apologize if this question is misplaced, I wasn't sure where to put it as the issues aren't strictly DSE related. I don't think so anyway. ^^'
Last edited by PoisionLullaby on Sat Feb 03, 2018 2:56 pm, edited 1 time in total.
~Everyone has bad days. Don't judge someone on that day and that day alone, judge them on their actions after it and onward.~

User avatar
Ocelot
Miko-Class Veteran
Posts: 849
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: renpy.random.choice repeating issuses

#2 Post by Ocelot » Wed Jan 31, 2018 1:02 pm

Technically the reason is that after event, sctipt tries to proceed further from call expression line, but there is no script after that, so it goes to the next label: normal_walk. I do not know how DSE is structured, but after call expression there should be something you usually do to end the event in DSE.
< < insert Rick Cook quote here > >

verysunshine
Veteran
Posts: 281
Joined: Wed Sep 24, 2014 5:03 pm
Organization: Wild Rose Interactive
Contact:

Re: renpy.random.choice repeating issuses

#3 Post by verysunshine » Wed Jan 31, 2018 2:48 pm

After you choose a random choice, press the "Shift" and "D" and click on "Variable Viewer". What do the variables related to that section of code say?

Build the basics first, then add all the fun bits.

Please check out my games on my itch.io page!

verysunshine
Veteran
Posts: 281
Joined: Wed Sep 24, 2014 5:03 pm
Organization: Wild Rose Interactive
Contact:

Re: renpy.random.choice repeating issuses

#4 Post by verysunshine » Thu Feb 01, 2018 12:15 pm

If you want to keep the "call expression", you could do:

Code: Select all

label go_outside:
    call expression renpy.random.choice(["run_into_creature", "normal_walk"]) #Gets a random choice, doesn't go to the label
    return #this sequence is done

label normal_walk:
    
    $ animal = renpy.random.choice(encounter)
    "You begin to walk down a small path in the forest. [animal]"
    $ stat += 10
    
    return #marks the end of the called expression

Build the basics first, then add all the fun bits.

Please check out my games on my itch.io page!

User avatar
PoisionLullaby
Regular
Posts: 42
Joined: Wed Jan 10, 2018 9:11 pm
Projects: We're all human
Deviantart: PoisionLullaby
Contact:

Re: renpy.random.choice repeating issuses

#5 Post by PoisionLullaby » Sat Feb 03, 2018 2:55 pm

I got the issue resolved but thank you both for all the help. :)
~Everyone has bad days. Don't judge someone on that day and that day alone, judge them on their actions after it and onward.~

Post Reply

Who is online

Users browsing this forum: No registered users