Inputs and randomize dialog?

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
Silvally
Newbie
Posts: 6
Joined: Sun Sep 16, 2018 9:45 pm
Contact:

Inputs and randomize dialog?

#1 Post by Silvally »

Hey so I started using Renpy and finally sitting down to learn it and while I'm getting a hang of things, I'm trying to do something where the character picks a choice randomly but you input text in itself. I've been staring at the input text screens but I don't fully understand how to do this.

So like Option A is your truth, Option B is your lie and the character has a 50% chance to pick either one of them.
If anyone would know how to code this and explain how it works, I'd really appreciate this. I'm not someone who codes a lot so ;;

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

Re: Inputs and randomize dialog?

#2 Post by Imperf3kt »

So basically you're presented the option to 'lie' and 'be truthful' and uopn selection, the player types what to reply?

You can use renpy.input to achieve that, but unless you're also detecting particular phrases / words, what purpose does it serve other than to force a player to type something?
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

Silvally
Newbie
Posts: 6
Joined: Sun Sep 16, 2018 9:45 pm
Contact:

Re: Inputs and randomize dialog?

#3 Post by Silvally »

Imperf3kt wrote: Mon Sep 17, 2018 1:36 am So basically you're presented the option to 'lie' and 'be truthful' and uopn selection, the player types what to reply?

You can use renpy.input to achieve that, but unless you're also detecting particular phrases / words, what purpose does it serve other than to force a player to type something?
I honestly don't fully know. I'm just trying to learn all aspects and grow myself, and tbh I don't fully understand renpy.input haha... sorry.

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

Re: Inputs and randomize dialog?

#4 Post by Imperf3kt »

Its an okay idea, I just suggest making more use of the typed reply.
Perhaps have it reappear later in conversation?
If you wait about 2~3 hours, I can post an example of how to do it.
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

Silvally
Newbie
Posts: 6
Joined: Sun Sep 16, 2018 9:45 pm
Contact:

Re: Inputs and randomize dialog?

#5 Post by Silvally »

Imperf3kt wrote: Mon Sep 17, 2018 1:40 am Its an okay idea, I just suggest making more use of the typed reply.
Perhaps have it reappear later in conversation?
If you wait about 2~3 hours, I can post an example of how to do it.
Anything would help ;; thank you

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

Re: Inputs and randomize dialog?

#6 Post by Imperf3kt »

Oops, completely forgot about this.
About to go to work, so this is kinda hurried, but this should do the trick.

Code: Select all

default my_reply = "anything"

label start:
    menu:
        "Lie":
            $ my_reply = renpy.input('What will you say?') or None
        "Be truthful":
            $ my_reply = renpy.input('What will you say?') or None
    
    "[my reply]"

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

Silvally
Newbie
Posts: 6
Joined: Sun Sep 16, 2018 9:45 pm
Contact:

Re: Inputs and randomize dialog?

#7 Post by Silvally »

Imperf3kt wrote: Mon Sep 17, 2018 4:09 pm Oops, completely forgot about this.
About to go to work, so this is kinda hurried, but this should do the trick.

Code: Select all

default my_reply = "anything"

label start:
    menu:
        "Lie":
            $ my_reply = renpy.input('What will you say?') or None
        "Be truthful":
            $ my_reply = renpy.input('What will you say?') or None
    
    "[my reply]"

I'm gonna try this! Thank you!

Silvally
Newbie
Posts: 6
Joined: Sun Sep 16, 2018 9:45 pm
Contact:

Re: Inputs and randomize dialog?

#8 Post by Silvally »

It's working and I'm seeing what I wanted to more now that I'm understanding the commands

Code: Select all

p "Okay then! What about you."
    m "What about me?"
    p "What's your truth and lie?"
    m "Oh... Uh..."

    $ my_reply = renpy.input('What is your lie?') or None
    $ my_reply = renpy.input('What is your truth?') or None

    p "Well. I choose... ["my reply"]" 
And where I have my reply, I want the character to pick one of the two replies you input randomly!

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

Re: Inputs and randomize dialog?

#9 Post by Imperf3kt »

So just to be sure I understand correctly, you want to allow a player to input a lie and input a truth, then have renpy randomly select one of those replies to use in the dialogue?

That should be easy enough to do and renpy includes a few ways to do the randomising.

I cannot give an example at this time, but if you check out the renpy documentation for renpy.randint or renpy.random, you might be able to work it out from the samples.

You could also present it as a screen, which would afford you more customisability, but that requires a little more work.

I'll try to help more when I have time enough to do so.
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

Silvally
Newbie
Posts: 6
Joined: Sun Sep 16, 2018 9:45 pm
Contact:

Re: Inputs and randomize dialog?

#10 Post by Silvally »

Imperf3kt wrote: Mon Sep 17, 2018 7:38 pm So just to be sure I understand correctly, you want to allow a player to input a lie and input a truth, then have renpy randomly select one of those replies to use in the dialogue?

That should be easy enough to do and renpy includes a few ways to do the randomising.

I cannot give an example at this time, but if you check out the renpy documentation for renpy.randint or renpy.random, you might be able to work it out from the samples.

You could also present it as a screen, which would afford you more customisability, but that requires a little more work.

I'll try to help more when I have time enough to do so.
Yeah! I really do appreciate it though whenever you can!

Post Reply

Who is online

Users browsing this forum: No registered users