ok many thanks, now renpy.hide works finaly.Also... a slight clarification of this latest suggestion...
Python:init python: def showme(img): renpy.show(img, behind="t") renpy.with_statement(Dissolve(0.5)) if store.previmg is not None: renpy.hide(store.previmg) store.previmg = img default previmg = None
The version slightly higher in this thread wasn't working because it was using a local variable. The workaround of parsing the image name back and then passing it again does work, but is a bit cumbersome. But storing the image name as part of the function was always an option, you just needed a global variable instead.
I'm not familiar with thebehind="t"
but copied it because... well, why not.
behind="t"
simply behind the textHow to set a global variable?
def:
lines) uses local variables. They only exist within that specific function and can't be accessed elsewhere.$ test1 = True
default test1 = True
label start:
that says if {varname} == {value}
, then that variable is what I'm describing as global.It mean that the shown sprite will be displayed behind the sprite named "t".I'm not familiar with thebehind="t"
but copied it because... well, why not.
Images are always behind the text. This unless the text is displayed as an image, what isn't a thing that should be just exceptionally done.behind="t"
simply behind the text
def mscene(img,trans):
renpy.scene()
renpy.show(img)
if trans == "":
renpy.with_statement(Dissolve(0.5))
elif trans == "cut":
pass
elif trans == "slow":
renpy.with_statement(Dissolve(1.5))
so if i putGenerally speaking, anything that is done within a function (thedef:
lines) uses local variables. They only exist within that specific function and can't be accessed elsewhere.
What I'm terming global variables are all the "normal" variables RenPy and your game uses.
So...
$ test1 = True
default test1 = True
... create (or update) global variables. In so much as they exist outside the functions at what I think of as that higher level accessible everywhere.
Or put another way... if you can imagine writing code afterlabel start:
that saysif {varname} == {value}
, then that variable is what I'm describing as global.
$ test1 = True
default test1 = True
Ok, you're going way too far for absolutely no reason :a funct for scene:
Python:def mscene(img,trans): renpy.scene() renpy.show(img) if trans == "": renpy.with_statement(Dissolve(0.5)) elif trans == "cut": pass elif trans == "slow": renpy.with_statement(Dissolve(1.5))
$
, and there's mandatory parenthesis and quotation marks absent from the statement syntax. And since everything now rely on the position of the value, it's also less intuitive than the statement and its properties.scene
statement permit many things, and I'm not totally sure that all can be expressed with your code.scene
statement evolve in the future, you'll have to change both the code and syntax of your function, what will force you to rewrite all your code using it.$ mscene("blabla","")
$ mscene("blabla","slow")
$ mscene("blabla","cut")
define slow = Dissolve( 1.5 )
define dissolve = Dissolve( 0.5 )
label whatever:
scene blabla with dissolve
scene blabla with slow
scene blabla
so if i put
$ test1 = True
default test1 = True
before label start
then i can manipulate
test1
in renpy and in python blocks?
init python:
which happens during game startup.$
is itself a python:
block, since $
effectively means "do single python command".default var1 = "Value"
default var2 = False
default var3 = 42
define e = Character("Eileen")
label start:
scene black with fade
"*** START ***"
$ var3 += 1
e "Welcome to my game, I'm [e]."
python:
for x in ...... : # some semi complex python command that can't be done in RenPy's native code
# # I dunno. My example is too simple to figure out what might go here.
e "Thanks for playing."
"*** THE END ***"
return
Just to say thanks!The only kink is that the generatedimage
displayables are named in lowercase. (So it's generally a good idea for files to be also named all in lowercase for your sanity).
Hmm... it depend how frequently you'll have to do that.How would I be able to assign a set of images that are displayed only if a player selects an 'alternate' start. These would be overlayed ontop of already existing images/dialogue, just provide extra world context.
if
:# Assuming that the /showWorldImages/ flag tell when the play have chosen to see the extra content.
label whatever:
# Display the base image
scene whatever
# If needed, display the extra content
if showWorldImages:
show whateverExtended
# Assuming that the /showWorldImages/ flag tell when the play have chosen to see the extra content.
# Generic label used to display the images
label myScene( imgName ):
# Firstly display the 'by default' image, accordingly to the name past as parameter.
scene expression imgName
# Then if the play asked to see the extra content, display the second image, which name
# is suffixed by "_extended" ; you can use something else as suffix, but it MUST be the
# same for all the images.
if showWorldImages:
show expression imgName + "_extended"
# Finally return to the game flow.
return
label whatever:
# Display the image named "whatever".
call myScene( "whatever" )
scene
, there's no need to hide the extended image, Ren'Py while do this automatically.scene
statement. A version that will take care of everything for you, like the "myScene" label is doing:python early hide:
# Parse the script.
def sceneExtendedParser( lex ):
# The name of the statement is already proceeded by Ren'Py, you just
# need to take care of the parameters. Here there's just one, the name
# of the image.
img = lex.image_name_component()
# Ensure that there's a none empty and valid image name.
if img is None: lex.error( 'image name is NOT optional' )
# Nothing more is needed.
lex.expect_eol()
# Provide the parameters to Ren'Py for further process.
return ( img, )
# Execute the statement.
def sceneExtendedExecute( t ):
# Clean the screen
renpy.scene()
# Show the 'base image'
renpy.show( t[0] )
# Show the extra content if needed.
# Here again, 'showWorldImages' is the default name for the flag,
# you can change it to something different, just don't forget the 'store.'
# prefix to be sure that it will always works fine.
if store.showWorldImages:
# Here again, you can replace the suffix by something else than
# "_extended", but you need to always have the same suffix for all
# the extra content images.
renpy.show( t[0] + "_extended" )
# Create the new statement named "sceneEx".
renpy.register_statement( 'sceneEx', parse=sceneExtendedParser, execute=sceneExtendedExecute )
scene
statement, and with the new sceneEx
statement. Which one to use depending if there's or not extra content available:label whatever:
# Display a regular image named "bathroom01.jpg" without extra content available.
scene bathroom01
[...]
# This display an image name "bathroom02.jpg", with an extra content image
# named "bathroom02_extended.jpg", that will be displayed only if the player
# decided it.
sceneEx bathroom02
Thank you so much for this detailed explanation.Now... you're probably thinking about renaming your image files to use spaces rather than underscores. That way, you don't need to manually add all those extraimage
statements. It's a pain in the arse. Better to stick to underscores, which is what applications like Daz3D will want to use anyway.
RenPy already has you covered.
Add this line into youroptions.rpy
file...
define config.automatic_images = [' ','_','-','/']
This will strip any of those characters out of the filename and create animage
statement using the removed characters as separators for the tagging system.
Because of the "/" in the list, that also means any subdirectory names are also processed too.
You can make use of this by picking directory names to aid the tagging system.
/images/bg/myroom01.jpg ->image bg myroom01 = "/bg/myroom01.jpg"
/images/bg/myroom02.jpg ->image bg myroom02 = "/bg/myroom01.jpg"
/images/eileen/smiling.png ->image eileen smiling = "/eileen/smiling.png"
/images/eileen/neutral.png ->image eileen neutral = "/eileen/neutral.png"
/images/eileen/sad.png ->image eileen sad = "/eileen/sad.png"
show images eileen happy
show eileen happy
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images' ]
## Custom Options ##############################################################
# activate automatic image importation
config.automatic_images = [ ' ', '_', '-', '/' ]
# allow to gather all images in the /game/images folder without having all the name starting with "images"
config.automatic_images_strip = [ 'images' ]