Replying through dialogue/ Artificial Intelligence based

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
isobellesophia
Miko-Class Veteran
Posts: 789
Joined: Mon Jan 07, 2019 2:55 am
Projects: Maddox and Friends 2020 aka (AI Teacher), Friendly Universities 2020-2021 (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: .......
Location: Philippines, Mindanao
Contact:

Replying through dialogue/ Artificial Intelligence based

#1 Post by isobellesophia » Mon Jan 27, 2020 7:19 am

Hello everyone.

Since many people asked about typed in coversation, i wanted to share it all of you.
This is called a typed in conversation or simply known as reply the character through dialogues.

This can be used in specific ways denpending on your game.
Note this is made by me, i hope this haven't been made yet, or maybe made it just today.

This also been familiarized to DDLC game named Monika's After Story or like that.
Maybe that is where you can speak to her whatever it is.
Note i didn't copied it, i made this by myself.

First, copy this. (Whatever where you want.)

Code: Select all

define user_input=[]
And then, this.

Code: Select all

label user:
    $ user_input = renpy.input(prompt = "Type anything you want!", allow="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ /.,'?!")

    $ user_input=user_input.lower().strip()

    if user_input == "": #This will happen if there's no input.

        a "You didn't type anything! You have to ask a question first."

        jump user
If didn't type anything, the character may insist you to write anything. But lazy to manage this code so i decided to put that instead.

Here is the main one, where what word you should type in, the Charac will talk back at you.

Code: Select all

if user_input in ['Hello!', 'Hello', 'hello!', 'hello']:
    ###Put it in like...
    a "Oh hi! How are you?"
    jump user
Whenever the character finishes talking, it will lead back to the label user, to talk something else more.

To make it more advanced, here it is, if you want to put more of them.

Code: Select all

if user_input in ['Hello!', 'Hello', 'hello!', 'hello']:
    ###Put it in like...
    a "Oh hi! How are you?"
    jump user
    
    elif user_input in ['I love you!', 'I love you', 'i love you!', 'i love you']:
    a "I love you too! Hugs and kisses! <3"
    jump user
    
    ....And so on.

This is special, if you didnt implement a keyword, the character will say this instead...
(Note, make sure to PLACE this one in the very bottom of the labels above, or else it may break the dialogues.)

Code: Select all

label untype:
    $ randdiag = renpy.random.randint(1, 10)
    show m think with dissolve
    if randdiag == 1:
        a "That word is invalid..."
        jump user
    elif randdiag == 2:
        a "Wywisjdow is not a word!"
        jump user
It can be also indicated by date, month, and also hour!

Code: Select all

init:
    $ import time
    $ year, month, day, hour, minute, second, dow, doy, dst = time.localtime()

Code: Select all

if user_input in ['What time is it?','what time is it?']:
        show a normal with dissolve
        a "The current time is [hour]: [minute]: [second]."
        jump user

Code: Select all

if month == 12 and day == 25:
        if user_input in ['Merry christmas!','merry christmas!','merry christmas','Merry christmas','Merry christmas alia!','merry christmas alia!','merry christmas alia','Merry christmas alia','Merry christmas Alia!','merry christmas Alia!','merry christmas Alia','Merry christmas Alia']:
            show a happyclosed with dissolve
            a "Merry christmas too [name]! Its good to talk to you this season!"
            jump user

    else:
        if user_input in ['Merry christmas!','merry christmas!','merry christmas','Merry christmas','Merry christmas alia!','merry christmas alia!','merry christmas alia','Merry christmas alia','Merry christmas Alia!','merry christmas Alia!','merry christmas Alia','Merry christmas Alia']:
            show a concerned with dissolve
            a "Umm.. i think its not christmas yet, you can wait."
            jump user

Also, a specifical answering.

Code: Select all

default goodmorning = False

Code: Select all

if user_input in ['Good morning','good morning','good morning!','Good morning!']:
        $ goodmorning = True
        show a happyclosed with dissolve
        a "Good morning! Have you drank some water before you wake up? Say yes if you are."
        jump user

    if goodmorning:
        if user_input in ['yes!','yes','Yes!','Yes']:
            show a normal 2 with dissolve
            a "Very good! Keep doing on that, so you will be stay hydrated."
            $ goodmorning = False
            jump user

        if user_input in ['no','No','Nope','nope','not yet','Not yet']:
            show a think with dissolve
            a "I see, then drink alot of it, it is recommended everyday!"
            $ goodmorning = False
            jump user
It will be set to False after, so that the character wont speak it again and again.

I hope you find it helpful to use it, i made alot of effort on doing it.
Have fun coding!
Last edited by isobellesophia on Mon Mar 02, 2020 11:11 pm, edited 1 time in total.
I am a friendly user, please respect and have a good day.


Working on a talking simulation game for everyone, except children.

Maddox and Friends
Is my very very main project, not contain 13 below.

Main project i currently working viewtopic.php?f=43&t=56564
Image

User avatar
HotMango
Newbie
Posts: 18
Joined: Wed Jan 15, 2020 10:36 pm
Skype: aboodal3deny
Contact:

Re: Replying through dialogue

#2 Post by HotMango » Mon Jan 27, 2020 4:25 pm

Wow
This is so helpful, it could be added in a visual novel but to make it more realistic that would take time.
Thank you so much!

User avatar
isobellesophia
Miko-Class Veteran
Posts: 789
Joined: Mon Jan 07, 2019 2:55 am
Projects: Maddox and Friends 2020 aka (AI Teacher), Friendly Universities 2020-2021 (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: .......
Location: Philippines, Mindanao
Contact:

Re: Replying through dialogue

#3 Post by isobellesophia » Tue Jan 28, 2020 11:45 am

I will be giving a example script soon, so newbies will be followed step by step, thanks for using.
I am a friendly user, please respect and have a good day.


Working on a talking simulation game for everyone, except children.

Maddox and Friends
Is my very very main project, not contain 13 below.

Main project i currently working viewtopic.php?f=43&t=56564
Image

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

Re: Replying through dialogue/ Artificial Intelligence based

#4 Post by verysunshine » Wed Mar 25, 2020 5:49 pm

If a string is modified with .lower, all capital letters become lower case. Besides that, this looks like some very useful code.

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

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

Post Reply

Who is online

Users browsing this forum: No registered users