Custom transform on event statement?

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
User avatar
tim640
Regular
Posts: 33
Joined: Wed May 23, 2018 4:47 pm
Contact:

Custom transform on event statement?

#1 Post by tim640 » Sat Nov 09, 2019 8:15 pm

Good evening!

So to put it short, there are transform conditions like "on show", "on hide", etc.
I was wondering, is it possible to create your own condition somehow? I need to transform an element, but only if a certain variable is toggled. Ideally, i'd have to be something like:

Code: Select all

transform test1: 

    on show:
        ...
    on hide:
        ...
    if variable == "off":
        ...
    if variable == "on":
        ...
But obviously, this can't work, so i guess there should be a way to define a custom condition here, like you do with user-defined actions i suppose. How do i properly do that? I read the cookbook page about atl transforms, but i couldn't find any real examples of implementing your own conditions.

Thank you in advance!

User avatar
gas
Veteran
Posts: 451
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Custom transform on event statement?

#2 Post by gas » Sat Nov 09, 2019 8:47 pm

Introducing such thing will be total chaos... on hide OR with variable == "on"? Both could be possibly True...
Anyway, I'll go inversely, selecting a different transform based on a variable by the screen itself..
10 ? "RENPY"
20 GOTO 10

RUN

User avatar
tim640
Regular
Posts: 33
Joined: Wed May 23, 2018 4:47 pm
Contact:

Re: Custom transform on event statement?

#3 Post by tim640 » Sat Nov 09, 2019 9:45 pm

Uh, yeah, my example is a bit confusing, sorry. I'll try to elaborate a bit. I am experimenting with transforms and UI animations to see what is actually possible and how visually appealing and smooth i can make it.

I've got a menu that opens by sliding up on "show", and closes up by sliding back down on "hide". Goes like this:

Code: Select all

transform jumpmenu:
    on show:
        ypos 810
        easein_bounce 0.7 ypos 0
    on replace:
        ypos 0
    on hide:
        easeout_quad 0.2 ypos 810
        linear 0 alpha 0
What i am trying to do is to make it slide up a bit more when you click a menu button so an additional screen with confirmation would be shown under it, and slide back when that additional screen is being hidden, while still retaining it's base "hide" and "show" slide animations. So it has to be a separate specific block in this transform, which wouldn't interrupt the other animations presented...

So what i came up with that imo could work (but then again, i can't find a way to imply it properly), is to create a variable -

Code: Select all

$ slideupmore = "on"
On the screen with the additional information, that is opening when you click a menu button, i put the following code:

Code: Select all

on "show":
        action SetVariable("slideupmore", "on")
on "hide":
        action SetVariable("slideupmore", "off")
So all that's left is to create a condition in the menu transform block, which would slide it up and down accordingly as the information screen is being shown and hidden.
I understand this is not a very elegant way of doing that, but i think it's gonna do what it should so there's that. It also -have- to be a separate screen like that since it's going to contain confirmation options as well. I can't find a better solution to this, since i am a beginner, so that's why i am posting here, uh.

If there's a way of defining a custom condition as i explained in the first post so i could try and also learn how to do such a thing in general (which would be very useful), i'd be extremely grateful for the information! Custom actions are game-changing (lol), knowing how to do custom transform conditions would be a total breakthrough.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]