Can i place RenPy statements within a Python block?

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
User avatar
SONTSE
Regular
Posts: 95
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 8 VN's so far
Contact:

Can i place RenPy statements within a Python block?

#1 Post by SONTSE » Fri Oct 03, 2014 7:49 am

Well, i do afraid this query leads to a really ugly coding solutions, but i was asked for this, and don't know the answer, so now i wonder.
Question is:
I know i can place a Python code within RenPy script, thats easy

Code: Select all

#my renpy statements
python:
    #my python statements
what i need is once i'm on a python block to make a renpy statements something like:

Code: Select all

#my renpy statements
python:
    #my python statements
    RenPy():
        #my other renpy statements
though i thats pretty much to expect, so maybe something like

Code: Select all

python:
    #my python statements
    renpy.execute([
        "transform transformexample:",
        "    xalign 0.0",
        "    linear 4 xalign 1.0",
        "    repeat"], init = True)
for now i think the best way to push renpy code within python block is statement equivalents, but i don't know equivalents to every statement,
and sometimes i don't have free time and/or effort to acknowledge, so need some solution that works no matter how ugly it is ^^ thanks for listen my tirades
Look! It's moving. It's alive. It's alive... IT'S ALIVE! Oh, in the name of God! Now I know what it feels like to be God!(@Henry_Frankenstein. Sums up my coding style)

User avatar
Ayutac
Regular
Posts: 150
Joined: Thu Oct 18, 2012 2:23 pm
Projects: Pokémon Dating Sim
Organization: A Breeze Of Science
Deviantart: Ubro
Location: Mayence, Germany
Contact:

Re: Can i place RenPy statements within a Python block?

#2 Post by Ayutac » Fri Oct 03, 2014 9:55 am

I don't know about the Ren'Py environment. But there are at leasr two ways to deal with that.

1. Find out the python commands.
E.g. this

Code: Select all

scene bg world
"You notice Eileen"
show Eileen happy at right with fade
Player "Hello Eileen!"
translates to this

Code: Select all

python:
    renpy.scene()
    renpy.show('bg world')
    narrator("You notice Eileen")
    renpy.transition(fade)
    renpy.show('Eileen happy', at_list=[right])
    Player("Hello Eileen!")
2. Put the Ren'Py code somewhere else.

Code: Select all

python:
    renpy.call('thingsHappen')
label thingsHappen(**kwargs):
    scene bg world
    "You notice Eileen"
    show Eileen happy at right with fade
    Player "Hello Eileen!"
    return
Please notice it's not important if you use "these" or 'these' quotation marks. I just like to visibilly divide dialog and simple strings.
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Can i place RenPy statements within a Python block?

#3 Post by Alex » Fri Oct 03, 2014 12:25 pm

Also, note that making all the coding inside a python block will lead to problems with saving / restoring your game - http://www.renpy.org/doc/html/save_load ... n-py-saves

User avatar
SONTSE
Regular
Posts: 95
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 8 VN's so far
Contact:

Re: Can i place RenPy statements within a Python block?

#4 Post by SONTSE » Fri Oct 03, 2014 5:56 pm

Thanks Ayutac for useful answer!
Ayutac wrote:1. Find out the python commands.
I think I gonna stick to that method, because...
Ayutac wrote:2. Put the Ren'Py code somewhere else.
Seems doesn't work quite right. running the following code...

Code: Select all

            python:
                e("python things happen")
                renpy.call('thingsHappen')
                e("another python things happen")
            label thingsHappen(**kwargs):
                "RenPy things happen"
                return
after narrating "RenPy things happen" it returns to Main Menu, as if "return" meaned the end of entire story.
Alex wrote:Also, note that making all the coding inside a python block will lead to problems with saving / restoring your game - http://www.renpy.org/doc/html/save_load ... n-py-saves
Thank you Alex for this important notice. I'll make sure savegame is not available while these scripts gonna run.

I think question is still up until i get clear answer that i cannot do it in a way i imagined(in which i almost sure now)
Look! It's moving. It's alive. It's alive... IT'S ALIVE! Oh, in the name of God! Now I know what it feels like to be God!(@Henry_Frankenstein. Sums up my coding style)

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_