Ren'py language vs standard python

Forum organization and occasional community-building.
Forum rules
Questions about Ren'Py should go in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
bugsyy
Newbie
Posts: 2
Joined: Sat Nov 07, 2020 4:19 am
Contact:

Ren'py language vs standard python

#1 Post by bugsyy »

Hi, I'm currently new to renpy so I just have few question about the diff between renpy language vs python:

1. is ""Init: python:"" equivalent to ""init python:"""
2. when creating a new python script and I want to use it in another script, do I have still have to use the "import" keyword?
3. Is it possible to use Ren'py code when defining a function in python? (or are there anyways to define a function in ren'py language)
4. What IDE do u guys usually use for ren'py and is it possible to use pycharm?
5. Recommended source to learn about the transform of stuff like xoffset/xposition/etc of an image or a screen stuff

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Ren'py language vs standard python

#2 Post by Imperf3kt »

-Init python: doesn't work with Ren'Py, only init pyton:
-import is not necessary if you've added the code to another script file already (Unless you're trying to reference the code before it exists)
-renpy does have its own pythonic equivalents for many things, but you can generally just use standard python in your function unless there's a specific reason to use the renpy version
-I just use Editra as my IDE. It works, and was packaged with Ren'Py when I first downloaded it. It has since been updated to Atom in the official builds, but I still prefer Editra and still use it.
- the documentation is always the most accurate, but not necessarily the best to learn from. ren'Py has a discord that may help as well.
https://www.renpy.org/doc/html/
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

bugsyy
Newbie
Posts: 2
Joined: Sat Nov 07, 2020 4:19 am
Contact:

Re: Ren'py language vs standard python

#3 Post by bugsyy »

So is"""
init python:
code
the same as
init:
python:
code
"""
sorry if my question wasn't clear ( what i meant was is init python the same as init: that takes in a python code block)
And do i need to have any reference code to an another rpy scripts or i don't need it ( such as I can just jump to a label that is in another script)
Also, are there any good coding tips on how things should be organized?

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Ren'py language vs standard python

#4 Post by gas »

Yes, they are equivalent.

Code: Select all

init python:
    # your codelines
is equal to say:

Code: Select all

init:
    python:
        # your codeline
The obvious difference is that in the first case you told that ALL lines that follow in the block MUST BE python lines. In the second case you can do a mixed thing.

As for referencing.
The moment you launch a game, renpy first scan the whole scripts. Do the init stuff wherever they are, ignoring the rest. They can be splitted between 3000 scripts, if you want for.
MIND THAT also the statements "DEFAULT" and "DEFINE" (and to my knowledge, "TRANSFORM") are registered at this point in time and can be put wherever you want.
Renpy execute the "init" things at any arbitrary order (mostly unpredictable). While this usually is not a problem, sometime you want to have the init define first something that you must use later in other init steps.
For this reason, you can use
init -x:
the lower the X the earlier the following block willbe executed in the init phase.

Code: Select all

init -10:
     # bla bla bla
init -20:
    # bla bla bla
The second block will be executed before the first.

THEN.
After this 'init' phase, it enter the main menu context. When you exitthe main menu context, it start from the "start" label where it can find it (as for default, you can state differently, but let's begin easily: it go to the start label).
From now onward it proceed line by line. If the ACTUAL script end without jumping somewhere else, renpy cnsider the game ended.
At any point, if you JUMP/CALL another label, you can JUMP/CALL to any label doesn't matter the actual script he does find it.
No need to quote it in advance. Renpy is able to find that label between 10.000 scripts you gave.
Again, it proceed line by line fromthat point onward and if reach the end of that text file and no more lines are there, it consider the game ended.

How things should be organized?
That depend on the lenght of your game.
As common practice, if a given kind of entry occupy big space, you should create a different script.
So, for example, if your game own 3000 characters, probably is quite better to create a new script, name it the way you want, and include here so much definitions.
Mind the logic above: as long as they are 'init' stuff, renpy will find them. If you need a given order, use init -x.

The same goes for labels. If you have a core script that jump back and forth a lot of sublabels, probably is better to write them on other script files. Renpy will be able to JUMP/CALL to wherever they are.

NOTE: the execution ignore screens blocks. That's mean if you're crazy enough you can define screens in the middle of a narration and renpy will ignore the entire block. The same, screens can be defined in whatever and as many scripts you want.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

Post Reply

Who is online

Users browsing this forum: No registered users