Triggered Looping Animations

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

Triggered Looping Animations

Postby Justintime9 » Thu Aug 26, 2010 12:51 pm

Hey,

I've just added an animated object to my age in which the player pushes a button and the object animates and loops endlessly until the button is pushed again. I tried using the Quickscript avatar animations and such, and for the animation script I set loop to 1 because I want it to loop when triggered.

However when I exported, the object had already started moving even though I didn't press the button. I made sure that autostart was off as well. The avatar animation works and the button is pushable, but what's the point if the object is already in motion? :P

Here's my AlcScripts:

Code: Select all
SirrusToy:
    animations:
        - name: SirrusRotate
          autostart: 0
          loop: 1
   
SirrusButton:
    quickscript:
        stateanimation:
            objectname: SirrusToy
            region: SirrusReg
            sdlname: SirrusTurn
            avatar:
                animation: ButtonTouch
                animtarget: SirrusTarget
            forewards:
                animation: SirrusRotate
            backwards:
                animation: SirrusRotate


As far as SDL file, I put one variable in. I assumed that although it looped, it would remember whether the object is in motion when the player links in later.
User avatar
Justintime9
 
Posts: 1180
Joined: Sat Sep 29, 2007 5:37 am

Re: Triggered Looping Animations

Postby D'Lanor » Thu Aug 26, 2010 5:54 pm

You cannot use the stateanimation quickscript for that. It was made for playing non-looping animations forwards or backwards. In both cases it sends the continue command. What you need though is the stop command.
"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: Triggered Looping Animations

Postby Justintime9 » Thu Aug 26, 2010 6:10 pm

Then what Quickscript should I have used? Can I just modify the stateanimation quickscript, or is there a completely different one I need?
User avatar
Justintime9
 
Posts: 1180
Joined: Sat Sep 29, 2007 5:37 am

Re: Triggered Looping Animations

Postby D'Lanor » Fri Aug 27, 2010 11:00 am

There is no quickscript for it but here is the full AlcScript.

Code: Select all
SirrusButton:
    logic:
        modifiers:
          - name: SirrusButtonClick
            cursor: poised
            flags:
              - localelement
            activators:
              - type: objectinvolume
                remote: SirrusReg
                triggers:
                  - any
            conditions:
              - type: activator
                activators:
                  - type: picking
              - type: objectinbox
                satisfied: true
            actions:
              - type: pythonfile
                ref: $BoolToggle
        actions:
          - type: pythonfile
            tag: BoolToggle
            pythonfile:
                file: xAgeSDLBoolToggle
                parameters:
                  - type: activator
                    ref: logicmod:SirrusButtonClick
                  - type: string
                    value: SirrusTurn
                  - type: skip
                  - type: skip
                  - type: string
                    value: SirrusTurn


SirrusToy:
    animations:
        - name: SirrusRotate
          autostart: 0
          loop: 1
    logic:
        actions:
          - type: pythonfile
            tag: IntStartStopResp
            pythonfile:
                file: xAgeSDLIntStartStopResp
                parameters:
                  - type: string
                    value: SirrusTurn
                  - type: responder
                    ref: $StartTurn
                  - type: string
                    value: 1
                  - type: bool
                    value: false
                  - type: responder
                    ref: $StopTurn
                  - type: bool
                    value: false
          - type: responder
            tag: StartTurn
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:SirrusTarget
                            callbacks:
                              - marker: ButtonTouch
                                receiver: respondermod:$StartTurn
                                user: 0
                        waiton: -1
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:SirrusToy
                            animname: SirrusRotate
                            cmds:
                              - continue
                        waiton: 0
                    nextstate: 0
                    ncallbacks: 1
                    waittocmd:
                      - key: 0
                        msg: 0
                curstate: 0
                flags:
                  - detecttrigger
          - type: responder
            tag: StopTurn
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:SirrusTarget
                            callbacks:
                              - marker: ButtonTouch
                                receiver: respondermod:$StopTurn
                                user: 0
                        waiton: -1
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:SirrusToy
                            animname: SirrusRotate
                            cmds:
                              - stop
                        waiton: 0
                    nextstate: 0
                    ncallbacks: 1
                    waittocmd:
                      - key: 0
                        msg: 0
                curstate: 0
                flags:
                  - detecttrigger


SirrusTarget:
    logic:
        actions:
          - type: oneshot
            name: SirrusTarget
            oneshot:
                animation: ButtonTouch
"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: Triggered Looping Animations

Postby Justintime9 » Fri Aug 27, 2010 2:08 pm

Ok, I just put that script in, and then deleted the .sav file. When I linked in I realized that I had forgotten to Apply scale and rotation (and at that point although nothing happened when I presses it, the button was clickable), but now I applied scale and rotation and the button isn't even clickable! At least the animation doesn't start automatically like it used to, but I can't figure out why the button would stop being clickable :P

is the "xAgeSDLBoolToggle" file the correct python file to reference?
User avatar
Justintime9
 
Posts: 1180
Joined: Sat Sep 29, 2007 5:37 am

Re: Triggered Looping Animations

Postby D'Lanor » Fri Aug 27, 2010 2:30 pm

Yes, it is correct. I have used this many times. Just make sure your clickable is set up correctly.
"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: Triggered Looping Animations

Postby Justintime9 » Fri Aug 27, 2010 4:14 pm

Ok. I checked again and the button is clickable, but when I push it, neither the avatar animation nor the object animation play. I checked and made sure that the button, animated object, and the region are Actors and have bounds, so it seems the clickable part is right. Thinking maybe if there was something wrong with the object itself, I created a completely new animation somewhere else in the age and the same thing happened.

Here's the second animations AlcScript:

Code: Select all
FMMButton:
    logic:
        modifiers:
          - name: FMMButtonClick
            cursor: poised
            flags:
              - localelement
            activators:
              - type: objectinvolume
                remote: FMMReg
                triggers:
                  - any
            conditions:
              - type: activator
                activators:
                  - type: picking
              - type: objectinbox
                satisfied: true
            actions:
              - type: pythonfile
                ref: $BoolToggle
        actions:
          - type: pythonfile
            tag: BoolToggle
            pythonfile:
                file: xAgeSDLBoolToggle
                parameters:
                  - type: activator
                    ref: logicmod:FMMButtonClick
                  - type: string
                    value: FMFall
                  - type: skip
                  - type: skip
                  - type: string
                    value: FMFall


FMMSphere:
    animations:
        - name: FMMFall
          autostart: 0
          loop: 1
    logic:
        actions:
          - type: pythonfile
            tag: IntStartStopResp
            pythonfile:
                file: xAgeSDLIntStartStopResp
                parameters:
                  - type: string
                    value: FMFall
                  - type: responder
                    ref: $StartTurn
                  - type: string
                    value: 1
                  - type: bool
                    value: false
                  - type: responder
                    ref: $StopTurn
                  - type: bool
                    value: false
          - type: responder
            tag: StartTurn
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:FMMTarget
                            callbacks:
                              - marker: DoorButtonTouch
                                receiver: respondermod:$StartTurn
                                user: 0
                        waiton: -1
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:FMMSphere
                            animname: FMMFall
                            cmds:
                              - continue
                        waiton: 0
                    nextstate: 0
                    ncallbacks: 1
                    waittocmd:
                      - key: 0
                        msg: 0
                curstate: 0
                flags:
                  - detecttrigger
          - type: responder
            tag: StopTurn
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:FMMTarget
                            callbacks:
                              - marker: DoorButtonTouch
                                receiver: respondermod:$StopTurn
                                user: 0
                        waiton: -1
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:FMMSphere
                            animname: FMMFall
                            cmds:
                              - stop
                        waiton: 0
                    nextstate: 0
                    ncallbacks: 1
                    waittocmd:
                      - key: 0
                        msg: 0
                curstate: 0
                flags:
                  - detecttrigger


FMMTarget:
    logic:
        actions:
          - type: oneshot
            name: FMMTarget
            oneshot:
                animation: DoorButtonTouch


And here's my SDL file:

Code: Select all
# Remember not to delete the existing versions when creating new SDL versions!
# Doing so could *corrupt* the vault!

STATEDESC TsoidahlPrad
{
    VERSION 1

    VAR BOOL    SirrusTurn[1]    DEFAULT=0
}

STATEDESC TsoidahlPrad
{
    VERSION 2

    VAR BOOL    SirrusTurn[1]    DEFAULT=0
    VAR BOOL    FMFall[1]    DEFAULT=0
}


Should there be a reference somewhere to my python file as well?
User avatar
Justintime9
 
Posts: 1180
Joined: Sat Sep 29, 2007 5:37 am

Re: Triggered Looping Animations

Postby Paradox » Fri Aug 27, 2010 5:21 pm

Indentation is wrong at
Code: Select all
FMMSphere:
    animations:
        - name: FMMFall
          autostart: 0
          loop: 1
"And one day I woke to find the future held no place for me. I was unwanted in a world, that with my hands I'd helped to build. Where once was honesty and pride, I now stand broken and alone."
Paradox
 
Posts: 1261
Joined: Fri Sep 28, 2007 6:48 pm
Location: Canada

Re: Triggered Looping Animations

Postby Justintime9 » Fri Aug 27, 2010 8:26 pm

Ah. Do you mean that

Code: Select all
FMMSphere:
    animations:
        - name: FMMFall
          autostart: 0
          loop: 1


should be

Code: Select all
FMMSphere:
    animations:
      - name: FMMFall
        autostart: 0
        loop: 1
?

because if so I just tried that and it didn't seem to change anything.
User avatar
Justintime9
 
Posts: 1180
Joined: Sat Sep 29, 2007 5:37 am

Re: Triggered Looping Animations

Postby D'Lanor » Sat Aug 28, 2010 4:58 am

Justintime9 wrote:Should there be a reference somewhere to my python file as well?

No, the only reference it needs is the name TsoidahlPrad which is there. And if you made a default TsoidahlPrad.py for your age then SDL states should work. We have confirmation of it from the quickscript (even though it did not do what you expected).

Can you post your export log file and the Python.0.elf log file?
"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

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron