two buttons for one animation

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

two buttons for one animation

Postby Justintime9 » Sat Nov 07, 2009 1:13 pm

I've been working on perfecting Shinelight Manor for the next release, and have decided to add a button to close the door to my office. The way it is now, is there is a button on the inside of the office that opens and closes the door. The problem however is that when it's opened, and the player enters the backroom, there's no way to close the door behind you.

I tried to fix it by adding a second button and clickregion, linked to the same SDL file and door animation

Image

and here's my AlcScript:

Code: Select all
AnimDoor:
    animations:
      - name: DoorAnim
        autostart: 0
        loop: 0

DoorButton:
    quickscript:
        stateanimation:
            objectname: AnimDoor
            region: ButtonRegion
            sdlname: DoorOpen
            avatar:
                animation: DoorButtonTouch
                animtarget: ButtonEmpty
            forewards:
                animation: DoorAnim
                animsound: DoorCreakEmpty
            backwards:
                animation: DoorAnim
                animsound: DoorCreakEmpty
   
InDoorButton:
    quickscript:
        stateanimation:
            objectname: AnimDoor
            region: InButtonRegion
            sdlname: DoorOpen
            avatar:
                animation: DoorButtonTouch
                animtarget: InButtonEmpty
            forewards:
                animation: DoorAnim
                animsound: DoorCreakEmpty
            backwards:
                animation: DoorAnim
                animsound: DoorCreakEmpty


However, when I exported it there was a problem. When I try to open the door from the office, it first warps me to the second button (the one on the other side of the door), does the door open animation, warps me back the the first button, and the door re-opens. The same thing happens if I press the button on the other side, or try to close the door. I have a hunch that it has to do with both clickregions/buttons being linked to the same door animation, but I can't be sure.
User avatar
Justintime9
 
Posts: 1188
Joined: Sat Sep 29, 2007 5:37 am

Re: two buttons for one animation

Postby D'Lanor » Sat Nov 07, 2009 7:26 pm

Right, that's exactly what you are telling it to do. When the SDL state changes it triggers two different responders at the same time. This will fail if:
a. they both contain a oneshot
b. they are doing the same animations

Cyans global scripts cannot handle this. You need to create a custom Python script which can pick the appropriate responder depending on which activator was clicked.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: two buttons for one animation

Postby Justintime9 » Sun Nov 08, 2009 10:18 am

ah, so all I have to do is add a script to my "MyAge.py" file? What would that script contain?
User avatar
Justintime9
 
Posts: 1188
Joined: Sat Sep 29, 2007 5:37 am


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron