Importing renpy functions?

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
TotemPollings
Newbie
Posts: 2
Joined: Wed May 30, 2018 1:14 am
Contact:

Importing renpy functions?

#1 Post by TotemPollings »

I'm looking to use the RenPy functions in my python script. Something like this in it's own separate function.py file:

Image

I'm just curious as I'm not well versed in python. I just ended up copying the renpy.py file from the renpy directory into my script folder and I can't follow it all that well to see where it's getting all it's functions from. More of a python question then a RenPy question.


P.S: I'm wondering if just doing this and not even bothering would be better:

Image

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: Importing renpy functions?

#2 Post by xavimat »

From rpy files you have access to all renpy functions. There is no need to import.
Your second example is the way to go, use init python to define your functions
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
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Importing renpy functions?

#3 Post by Remix »

Note though:

Ren'py exposed all functions from renpy/exports.py in the global namespace (which in turn imports a couple of modules and a host of named functions and classes)

Only those functions can be referenced through renpy.reference_name ( e.g. renpy.roll_forward_info() is valid whereas renpy.LiveComposite() is not )

To reference a function or class from one of the non-exports-exposed modules, just full dot path naming ( e.g. renpy.display.layout.LiveComposite() )

Basically, if you cannot reference it just with renpy.reference_name, find it and use full path ...
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: AWizardWithWords, piinkpuddiin