Page 1 of 1

renpy.random.choice repeating issuses [solved]

Posted: Wed Jan 31, 2018 11:40 am
by PoisionLullaby
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. ^^'

Re: renpy.random.choice repeating issuses

Posted: Wed Jan 31, 2018 1:02 pm
by Ocelot
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.

Re: renpy.random.choice repeating issuses

Posted: Wed Jan 31, 2018 2:48 pm
by verysunshine
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?

Re: renpy.random.choice repeating issuses

Posted: Thu Feb 01, 2018 12:15 pm
by verysunshine
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

Re: renpy.random.choice repeating issuses

Posted: Sat Feb 03, 2018 2:55 pm
by PoisionLullaby
I got the issue resolved but thank you both for all the help. :)