morganw, trooper6 and Divona are all right but none of them actually answered the question
Code: Select all
golf = "golf.jpg"
renpy.show("golf")
renpy.hide("golf")
This code can be rigged to work in renpy but it should not, at least according to documentation. The first and only argument to the renpy.show function is "name", which is the name of the tag associated with the displayable you which to show (in this case an image). The only way to permanently (for the duration of the game) tag an image in renpy as all three pointed out is:
or python equivalent of the same:
Code: Select all
init python:
renpy.image("golf", "golf.jpg")
both of which can only be executed in the init phase.
Code: Select all
renpy.show("golf")
renpy.hide("golf")
or show/hide in Ren'Py script will both display and hide them correctly.
=====================================>>>
The thing is that while it may be useful when showing images in Ren'Py script or screens cause of the automatic image prediction system, it is not even remotely useful to do when using renpy.show() because you would have to predict them manually anyway. Answering the actual question, proper/most used Python code to show/hide an image in Ren'Py is:
Code: Select all
renpy.show("temp_tagname", what=Image("golf.jpg"))
renpy.hide("temp_tagname")
without any declarations. If you wish to use an interim variable like:
than:
Code: Select all
renpy.show("temp_tagname", what=Image(golf))
renpy.hide("temp_tagname")
will still work. Whenever your use "what" keyword argument, temporary tag will be created for you internally, which you can use to hide the displayable later. I hope this answers the question.
=====================================>>>
most of the stuff in cookbook no longer work, you can see the errors yourselfs.
Most of the stuff in cookbook is not maintained/updated by the respective posters and some of it is poorly written code. As Ren'Py evolves, stuff is bound to break
and there is very little to no moderation to Q&A/Cookbook sections.