Including a python Text Adventure in a VN?

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
Liquid155
Newbie
Posts: 4
Joined: Thu May 30, 2013 11:07 pm
Contact:

Including a python Text Adventure in a VN?

#1 Post by Liquid155 »

I've come up with a short, simple text adventure game (a la Zork) that I would like to include in a visual novel I'm working on. Basically I want to have a menu option in Ren'Py that when clicked on pulls up the game. Then, once the (text adventure) game is finished, it returns to the visual novel.

I know there is Renpygame for including games made with pygame in Ren'Py, but this TA game I have is just straight made with python. Is there a way to incorporate it?

I have attached the file if anyone would like to take a look. I know Ren'Py can accept Python commands, but I don't know about running something like this. I thought it might be possible to include the TA game as a separate file and give Ren'Py the instruction to run it but I don't know if that's possible. This is the first thing I've ever written in Python and I'm kinda lost :?
Attachments
Hide and Seek.py
Python Text Adventure game.
(4.37 KiB) Downloaded 185 times

User avatar
Karl_C
Veteran
Posts: 232
Joined: Sun Mar 31, 2013 6:18 am
Contact:

Re: Including a python Text Adventure in a VN?

#2 Post by Karl_C »

Did you read Ren'Py's documentation already?
Python Modules in Ren'Py
Python and Ren'Py

Liquid155
Newbie
Posts: 4
Joined: Thu May 30, 2013 11:07 pm
Contact:

Re: Including a python Text Adventure in a VN?

#3 Post by Liquid155 »

Karl_C wrote:Did you read Ren'Py's documentation already?
Python Modules in Ren'Py
Python and Ren'Py
I did read the documentation, but when I try importing the module I get an error "EOFError: EOF When reading a line". If I comment out the $ import the Ren'Py part works fine, but when I include it I get that error before it even launches.

I'm wondering if it's having trouble importing it because the module runs through a Python Shell and Ren'Py doesn't have a way to process that?

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Including a python Text Adventure in a VN?

#4 Post by apricotorange »

Your game is using Python functions that generally should not be used from within Ren'Py; looking at it quickly, I spotted sleep(), raw_input(), and print(). (The use of raw_input() is probably causing the exception.) To convert it, you probably want to get rid of the sleep() calls, replace the raw_input() calls with calls to renpy.input(), and replace the calls to print() with calls to renpy.store.narrator(), or something along those lines.

Liquid155
Newbie
Posts: 4
Joined: Thu May 30, 2013 11:07 pm
Contact:

Re: Including a python Text Adventure in a VN?

#5 Post by Liquid155 »

apricotorange wrote:Your game is using Python functions that generally should not be used from within Ren'Py; looking at it quickly, I spotted sleep(), raw_input(), and print(). (The use of raw_input() is probably causing the exception.) To convert it, you probably want to get rid of the sleep() calls, replace the raw_input() calls with calls to renpy.input(), and replace the calls to print() with calls to renpy.store.narrator(), or something along those lines.
That has stopped it crashing, thank you!

Now it can mostly load the game. All it shows in Ren'Py is the "What do you do?" Question and prompt for input, but none of the other stuff. I was able to move around and 'seek', but it didn't tell me what I was doing. I figure I just have to tweak it for Ren'Py now that it's loading the module without crashing, maybe work something out in NVL mode.

EDIT: Looking at it again, it seems Ren'Py isn't showing anything printed with renpy.store.say (I changed it to this instead of renpy.store.narrator as narrator was causing errors) but it is showing the line printed with renpy.store.input

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Including a python Text Adventure in a VN?

#6 Post by apricotorange »

Not sure what's going on... the general documentation is http://www.renpy.org/doc/html/statement ... lents.html .

Liquid155
Newbie
Posts: 4
Joined: Thu May 30, 2013 11:07 pm
Contact:

Re: Including a python Text Adventure in a VN?

#7 Post by Liquid155 »

I have uploaded the new python code that loads without crashing, and a Ren'Py game that loads the module. If you run it you can see that it displays the "What do you do now?" line from the module, and accepts input, but does not print any of the text from the game. I'm stumped :(

The module actually functions, you can move around to the different areas and if you type 'seek' in each one you will eventually win the game (Which closes Ren'Py, though it's not supposed to, but I'll figure that out when it comes to it). The module is running successfully, it's just not printing any of the stuff it should be. Which is kinda important for a Text Adventure game.
Attachments
hsrenpy.py
Text Adventure code slightly modified to work in Ren'Py (This version will not work outside Ren'Py)
(4.67 KiB) Downloaded 160 times
renpy-textadventuretest.zip
Modified version of the Renpygame framework demo that runs my game instead (Loads the module successfully, but doesn't play right)
(591.89 KiB) Downloaded 96 times

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Including a python Text Adventure in a VN?

#8 Post by apricotorange »

Code: Select all

renpy.store.say=('\nNorth')
say() is supposed to be a function; why are you assigning strings to it?

Post Reply

Who is online

Users browsing this forum: bilmem, Silac