Writing answers instead of choosing menu options [EDITED]

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.
Message
Author
User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Writing answers instead of choosing menu options

#46 Post by xavimat »

jw2pfd wrote:I hope my rambling answered your question in some capacity.
Yes, thanks.
I, indeed, enjoyed the game this way. I wrote sentences knowing that I was "playing" like an actor (or like in life-role-playing).

@TrickWithAKnife: I can imagine a game in which the responses of the player affect, for example, stats. But the "complexity of language" (as jw2pfd points out) makes it very difficult. Maybe it could be done with hints to the user (words that he/she knows that affect one stat or another).
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Kokoro Hane
Eileen-Class Veteran
Posts: 1237
Joined: Thu Oct 27, 2011 6:51 pm
Completed: 30 Kilowatt Hours Left, The Only One Girl { First Quarter }, An Encounter ~In The Rain~, A Piece of Sweetness, Since When Did I Have a Combat Butler?!, Piece by Piece, +many more
Projects: Fateful Encounter, Operation: Magic Hero
Organization: Tofu Sheets Visual
Deviantart: kokoro-hane
itch: tofu-sheets-visual
Contact:

Re: Writing answers instead of choosing menu options

#47 Post by Kokoro Hane »

Hi! I am having a problem with the code.

It seems that now I have it in my project, the choice menus don't work anymore. When I go back to my saved games with choice menus, an error comes up saying "reply_screen" not defined. Does this code replace the choice menu function? Because when I use $ menu = nvl _menu, it works just find (since I use nvl_menu for the yielded search results). Is there a way where I can still have my regular choice menu and the reply code?
PROJECTS:
Operation: Magic Hero [WiP]
Piece By Piece [COMPLETE][Spooktober VN '20]
RE/COUNT RE:VERSE [COMPLETE][RPG]
Since When Did I Have a Combat Butler?! [COMPLETE][NaNoRenO2020+]
Crystal Captor: Memory Chronicle Finale [COMPLETE][RPG][#1 in So Bad It's Good jam '17]

But dear God, You're the only North Star I would follow this far
Owl City "Galaxies"

TrickWithAKnife
Eileen-Class Veteran
Posts: 1261
Joined: Fri Mar 16, 2012 11:38 am
Projects: Rika
Organization: Solo (for now)
IRC Nick: Trick
Location: Tokyo, Japan
Contact:

Re: Writing answers instead of choosing menu options

#48 Post by TrickWithAKnife »

xavimat wrote:
jw2pfd wrote:I hope my rambling answered your question in some capacity.
Yes, thanks.
I, indeed, enjoyed the game this way. I wrote sentences knowing that I was "playing" like an actor (or like in life-role-playing).

@TrickWithAKnife: I can imagine a game in which the responses of the player affect, for example, stats. But the "complexity of language" (as jw2pfd points out) makes it very difficult. Maybe it could be done with hints to the user (words that he/she knows that affect one stat or another).
Of course, especially with a language like English, but there are things that are possible to increase the chances of the input being understood. Even better, if the code is freely available to use and build upon, it should gradually become more effective.

One thing is for certain: users are going to write weird things that you'll never expect.

Example:
Game: "Would you like to go to a park, beach or mountain?"
Expected response: "I want to go to a mountain."
Actually response: "I'd like to go somewhere cold."
If the three keywords contained key information it might be possible. Beach could contain [sand, ocean, sea, hot], park could contain [trees, grass, hill, green], mountain could contain [white, cold, snow, ice, skiing].
"We must teach them through the tools with which they are comfortable."
The #renpy IRC channel is a great place to chat with other devs. Due to the nature of IRC and timezone differences, people probably won't reply right away.

If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Writing answers instead of choosing menu options

#49 Post by xavimat »

Kokoro Hane wrote:Hi! I am having a problem with the code.

It seems that now I have it in my project, the choice menus don't work anymore. When I go back to my saved games with choice menus, an error comes up saying "reply_screen" not defined. Does this code replace the choice menu function? Because when I use $ menu = nvl _menu, it works just find (since I use nvl_menu for the yielded search results). Is there a way where I can still have my regular choice menu and the reply code?
I don't know why you have this error.
This code only uses "renpy.input()", not the "choice menu". And it doesn't change nor define screens. It uses the defined "input" screen.
Are you calling a "reply screen"?
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: Writing answers instead of choosing menu options

#50 Post by jw2pfd »

Okay, so, I decided to rebuild a system that checks for keywords and synonyms from the ground up. I feel that it's off to a better start than what I had coded in The Dolls' Stories. My code for that project was too specific to its purposes. I have attached a zip of two script files that can simply be pasted into a new project's game folder if you want to launch and test it. The .rpy files themselves are commented a bunch, but there isn't a lot of explanation in the project itself as of right now.

The purpose of this code is not to replace xavimat's code in the original post. My code essentially does the same thing, but I wanted to add the feature of assigning words synonyms or equivalent statements. I felt that the best way to do that was to implement the code using classes which meant doing entirely new code as opposed to augmenting xavimat's code. I know Trick was suggesting this functionality, but I am not sure how many other people will really utilize these features.

I didn't really feel like my code warranted a new thread given that it's a part of this thread's discussion.
Attachments
sentence-1.0.zip
sentence.rpy - contains class code
script.rpy - a file utilizing class code for example purposes
(5.11 KiB) Downloaded 140 times

User avatar
Kokoro Hane
Eileen-Class Veteran
Posts: 1237
Joined: Thu Oct 27, 2011 6:51 pm
Completed: 30 Kilowatt Hours Left, The Only One Girl { First Quarter }, An Encounter ~In The Rain~, A Piece of Sweetness, Since When Did I Have a Combat Butler?!, Piece by Piece, +many more
Projects: Fateful Encounter, Operation: Magic Hero
Organization: Tofu Sheets Visual
Deviantart: kokoro-hane
itch: tofu-sheets-visual
Contact:

Re: Writing answers instead of choosing menu options

#51 Post by Kokoro Hane »

xavimat wrote:
Kokoro Hane wrote:Hi! I am having a problem with the code.

It seems that now I have it in my project, the choice menus don't work anymore. When I go back to my saved games with choice menus, an error comes up saying "reply_screen" not defined. Does this code replace the choice menu function? Because when I use $ menu = nvl _menu, it works just find (since I use nvl_menu for the yielded search results). Is there a way where I can still have my regular choice menu and the reply code?
I don't know why you have this error.
This code only uses "renpy.input()", not the "choice menu". And it doesn't change nor define screens. It uses the defined "input" screen.
Are you calling a "reply screen"?
Hmm, I'll have to check the code and see what I did...
PROJECTS:
Operation: Magic Hero [WiP]
Piece By Piece [COMPLETE][Spooktober VN '20]
RE/COUNT RE:VERSE [COMPLETE][RPG]
Since When Did I Have a Combat Butler?! [COMPLETE][NaNoRenO2020+]
Crystal Captor: Memory Chronicle Finale [COMPLETE][RPG][#1 in So Bad It's Good jam '17]

But dear God, You're the only North Star I would follow this far
Owl City "Galaxies"

User avatar
Kokoro Hane
Eileen-Class Veteran
Posts: 1237
Joined: Thu Oct 27, 2011 6:51 pm
Completed: 30 Kilowatt Hours Left, The Only One Girl { First Quarter }, An Encounter ~In The Rain~, A Piece of Sweetness, Since When Did I Have a Combat Butler?!, Piece by Piece, +many more
Projects: Fateful Encounter, Operation: Magic Hero
Organization: Tofu Sheets Visual
Deviantart: kokoro-hane
itch: tofu-sheets-visual
Contact:

Re: Writing answers instead of choosing menu options

#52 Post by Kokoro Hane »

Just want to let you know I discovered the problem, and it had nothing to do with this code, but another code I was using (simple fix; a certain flag had to be set underneath the Start label).
PROJECTS:
Operation: Magic Hero [WiP]
Piece By Piece [COMPLETE][Spooktober VN '20]
RE/COUNT RE:VERSE [COMPLETE][RPG]
Since When Did I Have a Combat Butler?! [COMPLETE][NaNoRenO2020+]
Crystal Captor: Memory Chronicle Finale [COMPLETE][RPG][#1 in So Bad It's Good jam '17]

But dear God, You're the only North Star I would follow this far
Owl City "Galaxies"

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Writing answers instead of choosing menu options [EDITED

#53 Post by xavimat »

Edited code. Now we have the two functions reply() and reply2() that return a single word and a list respectively.
Added also a link to jw2pfd's code.
Check the OP here: http://lemmasoft.renai.us/forums/viewto ... 93#p266393
Thanks to all who have contributed to this.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
rabcor
Regular
Posts: 81
Joined: Sun Mar 17, 2013 3:07 pm
Projects: None (Need a programmer?)
Organization: Cestarian Games
Contact:

Re: Writing answers instead of choosing menu options [EDITED

#54 Post by rabcor »

That's pretty cool, i had thought about using something similar in my current project, but still haven't decided. Thanks for the code :D

My idea of it was inspired by wizardry 8 (Lower right corner, there's a textbox for the player to write in, he can select to "talk about" or "where is" what he typed in, any dialogues that actually work get added to the list above the textbox. When critcal Yes/No choices happen in dialogue it uses a "Yes/No" menu, VN style.)

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Writing answers instead of choosing menu options [EDITED

#55 Post by xavimat »

rabcor wrote:That's pretty cool, i had thought about using something similar in my current project, but still haven't decided. Thanks for the code :D
My idea of it was inspired by wizardry 8 (Lower right corner, there's a textbox for the player to write in, he can select to "talk about" or "where is" what he typed in, any dialogues that actually work get added to the list above the textbox. When critcal Yes/No choices happen in dialogue it uses a "Yes/No" menu, VN style.)
You're welcome!

I haven't played that (seems pretty complex).
If you have a (simple) suggestion, maybe I can try. :)
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
finnlawrence
Newbie
Posts: 11
Joined: Mon Dec 24, 2012 11:35 am
Contact:

Re: Writing answers instead of choosing menu options [EDITED

#56 Post by finnlawrence »

Is there any way to adjust this code so that you can put a jump statement in place of saying something? For example, if you wanted to jump to a 'game over' screen if the player typed in the wrong answer.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Writing answers instead of choosing menu options [EDITED

#57 Post by xavimat »

finnlawrence wrote:Is there any way to adjust this code so that you can put a jump statement in place of saying something? For example, if you wanted to jump to a 'game over' screen if the player typed in the wrong answer.
Easy!
I suggest a simple way. Change this lines:

Code: Select all

            if found_it == "":
                renpy.say(invalid_character, invalid_answer)
With this:

Code: Select all

            if found_it == "":
                found_it = "WRONG"
Then, the function will return the word WRONG if no keyword is found in the player's entry.
With if-elif-else, you can jump or call what you need.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: No registered users