Need help with making multiple random scenes go off

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
Jaitzche
Newbie
Posts: 13
Joined: Sun Jan 07, 2018 1:26 am
Contact:

Need help with making multiple random scenes go off

#1 Post by Jaitzche »

I'm super new to this but I'm trying for a certain affect. It mostly works except it's setting off the wrong random scenes on occasion and I don't know if it's a coding issue or if there's something more that I need that I haven't learned about yet. My code for the most part looks like this-

Code: Select all

label talk:
$ rand_themtalk = renpy.random.randint(1,2)
if rand_themtalk == 1 and talking: #the second part just to show that I'm trying to only 
					 trigger it if there's a second variable at play (mentioning as 
					 I'm not sure if it might be part of the problem)
	$ you_talk = "Some words"
if rand_themtalk == 2 and talking:
	$ you_talk = "Some other words.
	
$ rand_youtalk = renpy.random.randint(1,2)
if rand_youtalk == 1 and fighting:
	$ you_talk == "Them's some fighting words."
if rand_youtalk == 2 and fighting:
	$ you_talk == "Some more fighting words."
	
	
	
menu:
	[you_talk]
	
	"Say something else" if talking:
		$ talking = True
		$ fighting = False
		jump talk
	"Fight it out" if fighting:
		$ talking = False
		$ fighting = True
		jump talk
	"Do something else":
		jump some_other_label 
Okay if that makes sense (I'd copy the actual code but it's about 10 times as long with a bunch of variables that I don't want to have to explain).

So, my problem is, say every time I jump back to the talk label, half the time it does it right, but the other half, instead of 'talking' it switches to 'fighting', and vice versa.

I checked my code to see if maybe I've messed up a = or something but so far I'm not seeing an issue. I was wondering if maybe it's they way I have the random part set up- putting two different randoms together, and it's not happy about it.

If this doesn't make sense I'll try to explain further.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Need help with making multiple random scenes go off

#2 Post by Per K Grok »

Jaitzche wrote: Fri Mar 22, 2019 3:31 am I'm super new to this but I'm trying for a certain affect. It mostly works except it's setting off the wrong random scenes on occasion and I don't know if it's a coding issue or if there's something more that I need that I haven't learned about yet. My code for the most part looks like this-

Code: Select all

label talk:
$ rand_themtalk = renpy.random.randint(1,2)
if rand_themtalk == 1 and talking: 

	$ you_talk = "Some words"
if rand_themtalk == 2 and talking:
	$ you_talk = "Some other words.                              ## closing " missing
	
$ rand_youtalk = renpy.random.randint(1,2)                   ## why a different variables for random value? You only use one of them.
if rand_youtalk == 1 and fighting:
	$ you_talk == "Them's some fighting words."          ##  double ==
if rand_youtalk == 2 and fighting:
	$ you_talk == "Some more fighting words."            ##  double ==
	
	
	
menu:
	[you_talk]                                                    ##  "   "  missing
	
	"Say something else" if talking:               ## if talking    the use of if talking and if fighting makes it impossible to change mode
		$ talking = True
		$ fighting = False
		jump talk
	"Fight it out" if fighting:                       ## if fighting   see above
		$ talking = False
		$ fighting = True
		jump talk
	"Do something else":
		jump some_other_label 
Okay if that makes sense (I'd copy the actual code but it's about 10 times as long with a bunch of variables that I don't want to have to explain).

So, my problem is, say every time I jump back to the talk label, half the time it does it right, but the other half, instead of 'talking' it switches to 'fighting', and vice versa.

I checked my code to see if maybe I've messed up a = or something but so far I'm not seeing an issue. I was wondering if maybe it's they way I have the random part set up- putting two different randoms together, and it's not happy about it.

If this doesn't make sense I'll try to explain further.

Some comments in the code above.

A working code

Code: Select all

default talking = True

label start:
    scene placeholder

label talk:

    $ rand_talk = renpy.random.randint(1,2)

    if talking:
        if rand_talk == 1:
            $ you_talk = "talk 1."
        else:
            $ you_talk = "talk 2."

    else:
        if rand_talk == 1:
            $ you_talk = "Fight 1."
        else:
            $ you_talk = "Fight 2."

    menu:
        "[you_talk]"

        "Say something else":
            $ talking = True
            jump talk

        "Fight it out":
            $ talking = False
            jump talk

        "Do something else":
            jump some_other_label



Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], MisterPinetree