using ATL "event" and "on" [solved]

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
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

using ATL "event" and "on" [solved]

#1 Post by Kia »

I found this http://www.renpy.org/doc/html/atl.html#event-statement and wondered if it's what I was looking for a long time?

lets say we have a transform:

Code: Select all

transform route:
    on e40:
        linear 1.0 rotate 40
and an object added somewhere with that transform:

Code: Select all

add "ui/menu.png"  at route
can I trigger that "e40" with firing some event?:

Code: Select all

textbutton _("do it") action "event" e40
since there is only few lines on these two (event and on) I can't figure out how it works and what it does. anyone knows about them?
Last edited by Kia on Thu May 28, 2015 12:41 am, edited 1 time in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: using ATL "event" and "on"

#2 Post by xela »

In ATL, event statement is used to pass instructions to a different block so no, it cannot be used the way you describe.

You can use a function passing a global to your set of ATL instructions or a simple if/else fork.
Like what we're doing? Support us at:
Image

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: using ATL "event" and "on"

#3 Post by Kia »

I did try something like:

Code: Select all

define rotee = 0
transform route:
    linear 1.0 rotate rotee
screen main_menu():
    add "ui/menu.png"  at route
    textbutton _("do it") action SetVariable('route', 40)
but it didn't work and while I was searching in the renpy's documentation I saw "event" and it distracted me. now I'm back to this and still can't figure what's wrong with it.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: using ATL "event" and "on"

#4 Post by xela »

Try something like (simple if/else way I mentioned earlier):

Code: Select all

transform my_rotate(degrees=0):
    subpixel True
    linear 1.0 rotate degrees
    
screen main_menu():
    default var = False
    
    showif var:
        add "ui/menu.png" at my_rotate(degrees=40)
    else:
        add "ui/menu.png" at my_rotate()
        
    textbutton _("do it") action ToggleScreenVariable('var')
You can obviously just add the image without the at statement in the else fork... I just threw it in as an example, this is untested so there could be spelling/small tech errors. The approach itself is sound, you prolly do not need showif here either, I usually use it in this cases so I do not forget it exists (can be really useful at times).
Like what we're doing? Support us at:
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: using ATL "event" and "on"

#5 Post by trooper6 »

I tried xela's code...which worked...but didn't give me the linear. So, inspired by xela's code, this is what I got to work:

Code: Select all

default rotee = 0

init python:
    def butt_rote():
        global rotee
        rotee += 40
        renpy.restart_interaction()

transform route(degrees=0):
    subpixel True
    linear 1.0 rotate degrees
    
screen main_menu():
    add "images/agentX angry.png" at route(rotee)
    textbutton _("do it") action Function(butt_rote)
Note: I'm using the pre-release 6.99.4
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: using ATL "event" and "on"

#6 Post by Kia »

I'm getting error for "default rotee = 0" on 6.99 so I guess my next step is downloading the new version ^_^
thanks for help xela, trooper6

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: using ATL "event" and "on"

#7 Post by xela »

Yeah... st is too old for that screen, my set of ATL instructions does not account for that. You'll have to reset troopers version so it doesn't keep adding up but it should work.
Like what we're doing? Support us at:
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: using ATL "event" and "on"

#8 Post by trooper6 »

Orz, if you don't know it, default only works with 6.99.4+, which is currently in pre-release. In order to get it, go to the preferences on the launcher,

xela is right, if you don't want the button to continuously add 40 degrees to the image (which I thought I'd try because I wanted to see if I could do it), in the butt_rote function change "rotee += 40" to "rotee = 40."

xela--I want to thank you so much for teaching me that transform definitions could take variables, i.e. "transform route(degrees=0)"
I had no idea! The ATL page doesn't show transform with parens...so I didn't think it was possible. How do you know which definitions can take variables like that if it isn't documented?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: using ATL "event" and "on"

#9 Post by xela »

trooper6 wrote: I had no idea! The ATL page doesn't show transform with parens...so I didn't think it was possible. How do you know which definitions can take variables like that if it isn't documented?
Ren'Py Documentation wrote: atl_transform ::= "transform" name "(" parameters ")" ":"
atl_block
It is documented... there are just no examples. There is a lot of stuff in Ren'Py that doesn't offer any examples, mainly because the engine allows to do far too many things in too many different ways in order to document them properly, so people are using the Q&Ann section in the forum to share knowledge.

One of the coolest things I found out just a week ago is how to use ATL instructions inside of CDDs through At() class. I've been using both for years but never put two and two together before working on Rhythm minigame with Kaen. I guess that some stuff you just figure out by trail and error with time.
Like what we're doing? Support us at:
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: using ATL "event" and "on"

#10 Post by trooper6 »

Huh! That is cool! Do you think you'd be able to put the rhythm example in the Cookbook so other could study your CCD At() revelation?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]