Page 1 of 1

Can i place RenPy statements within a Python block?

Posted: Fri Oct 03, 2014 7:49 am
by SONTSE
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

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

Posted: Fri Oct 03, 2014 9:55 am
by Ayutac
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.

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

Posted: Fri Oct 03, 2014 12:25 pm
by Alex
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

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

Posted: Fri Oct 03, 2014 5:56 pm
by SONTSE
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)