Yes, but in the same time, no.
There's the
You must be registered to see the links
configuration variable that can do this. But its use is really limited. It isn't called when the file associated to an image is missing, but when there's no image declared (explicitly or implicitly) with the expected name.
Therefore,
Code:
label start:
show DoNotExist
will trigger the callback, but
Code:
image IsMissing = "MissingImage.jpg"
label start:
show IsMissing
will not, and throw an error saying that the file is missing. It's probably the same if the error happen inside a dynamic or layered image, or inside an interpolated image.
And unlike what the documentation lets think, using
You must be registered to see the links
is of no help here, because it can only tell if the image is loadable or not ; at no time it offer you the possibility to change the name of the file.
As for intercepting the exception... The version 7.3.5 introduced a configuration callback for that,
You must be registered to see the links
, but it's designed to treat the exception differently, not to change the behavior. So it's not really possible to do something with it.
If the callback return
False
, Ren'py will handle the exception by itself, and show the traceback. And if the callback return
True
, Ren'py will ignore the statement... which would be good if the exception wasn't thrown after every single statement, because each time Ren'py try to display the image.
Therefore if you have something like :
Code:
image IsMissing = "DoNotExist1.jpg"
label start:
show DoNotExist
"Welcome to my game, please wait an instant, I init the values."
call initVar
"Alright, we are ready to go, so first thing first..."
$ mcName = renpy.input( "Please, what's your name ?" )
"Glad to encounter you, [mcName]."
"We are ready to start."
hide DoNotExist
[...]
All the part between
show DoNotExist
and
hide DoNotExist
will be skip. It's worse if you use
scene
, because all the following
scene
will throw the error and so be ignored...
In top of that, the callback don't have raw arguments, but already formatted ones. So it would be a pain in the ass to identify the effective problem and solve it.
For the code above, the first argument would be :
[note: yes, the error do not appear at the
show
line.]
The second would be the full traceback, totally useless in this case. And the last argument would be the path to the traceback file.
Therefore, you have no possibility to know what image triggered the exception, and so no possibility to hide it and save the day.
This said,
theoretically there's still a possibility. You need to overwrite
renpy.show
and
renpy.scene
. Something like :
[WARNING, totally untested, it's pure theoretical code]
Code:
init python:
def myShow( name, *args, **kwargs ):
try:
showOriginal( name, *args, **kwargs )
except:
renpy.hide( name )
showOriginal( placeholder )
showOriginal = renpy.show
renpy.show = myShow
image placeholder = "placeholder.jpg"
I don't remember the Python equivalent
scene
(which is NOT
renpy.scene
) but the principle is the same ; you try to display the image, and in case of error you show something else.