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.
I know how to animate a textbox so it plays every time you click, but the problem is that I want the textbox to only move either when a new character shows up or when the scene changes. The specific animation I want is the textbox to pop up from the bottom when it shows up, and for it to move down when it has to hide.
I tried using this, but I can't get the textbox to pop up again after starting the game, even if I use "window hide" and "window show"
It looks like your problem is a typo where you have "function say_window_tranform_reset" instead of "function say_window_transform_reset". Though, that should throw an error and you didn't mention one.
zmook wrote: ↑Sun Mar 21, 2021 12:33 pm
It looks like your problem is a typo where you have "function say_window_tranform_reset" instead of "function say_window_transform_reset". Though, that should throw an error and you didn't mention one.
in your say screen, but it won't work at all without that, if I understand you right it does work the first time.
Do either of those fix your problem?
My bad, I didn't include the fixed typo or the window code on there. I already had both, but it just seems the effect itself doesn't do what I specifically want. It seems to only pop up at the very beginning of my game. After that, it defaults to a Dissolve effect (which I fiddled around and set the default window hide/show animation to None, but that didn't help at all.)
init python:
def say_window_transform(trans, st, at):
global say_window_show_transform
if not "say_window_show_transform" in globals():
say_window_show_transform = False
if say_window_show_transform == False:
trans.yoffset = 250
say_window_show_transform = True
if say_window_show_transform == True:
if st > 0.5:
trans.yoffset = 0
return None
else:
trans.yoffset -= trans.yoffset * st
return 0
else:
return None
def say_window_transform_reset(trans, st, at):
global say_window_show_transform
say_window_show_transform = False
transform say_window_animation:
on show:
function say_window_transform
on hide:
yoffset 0
linear 0.3 yoffset 250
function say_window_transform_reset
screen say(who, what):
style_prefix "say"
window:
at say_window_animation
id "window"
if who is not None:
window:
style "namebox"
text who id "who"
text what id "what" at text_fade_in
I figured out the issue here is the "on hide" command since what I assume the code is supposed to do is reset the window showing animation whenever I write "window hide", but clearly that isn't working. All it does is go to the default Dissolve that is on config.window_hide_transition. I have asked around and I guess "on hide" just doesn't work here. Any ways to replace that? I'm gonna go crazy if I can't figure out this textbox.
Transient screens do not recognize the hide event so will not play nicely with transforms like that.
One approach might be to use show_layer_at to affect an entire layer...
(this example plops the say screen on a new layer so as not to bork other screens)
Remix wrote: ↑Wed Apr 14, 2021 6:37 pm
Transient screens do not recognize the hide event so will not play nicely with transforms like that.
One approach might be to use show_layer_at to affect an entire layer...
(this example plops the say screen on a new layer so as not to bork other screens)
init python:
renpy.add_layer(layer='say_screen', above="screens", menu_clear=True)
config.say_layer = "say_screen"
transform retract():
yoffset 0
linear 2.0 yoffset 400
## yup, adjust as wanted and add an expand or whatever transform to bring it back...
label start:
scene expression '#CCC'
"words"
$ renpy.show_layer_at(at_list=[retract], layer='say_screen')
pause
Thank you so much, this works great. If it's not too greedy to ask, would it be possible to optimize this even further? Implementing this seems to work like this:
I have to write two lines of code just for this to work. It's not the worst thing in the world, and I'd rather have it than nothing. But if possible, one line would be beautiful or, most preferably, changing automatically when a different character begins to speak or when I use "window hide". I assume "last_say_who" would be where to start, but I can't fathom how to make that work.
Thank you once again, sorry for asking for so much.
filthsama wrote: ↑Wed Apr 14, 2021 6:58 pmI have to write two lines of code just for this to work. It's not the worst thing in the world, and I'd rather have it than nothing. But if possible, one line would be beautiful ...
Than just call this function in place of your two outrageous lines ?
filthsama wrote: ↑Wed Apr 14, 2021 6:58 pm... or, most preferably, changing automatically when a different character begins to speak or when I use "window hide". I assume "last_say_who" would be where to start, but I can't fathom how to make that work.