2 buttons to the same animation

If you feel like you're up to the challenge of building your own Ages in Blender or 3ds Max, this is the place for you!

2 buttons to the same animation

Postby Justintime9 » Sat Feb 06, 2010 8:31 am

I have a door in my age that I want to be opened with two buttons. (one on one side of the door and one on the other.) The problem is I'm not sure how to do this without it acting strangely. I've tried it in the past and when I press one button it makes me press the other right after that. Here's the script for my animation:

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


Would I just create another button, clickregion, and target empty, and link it to the same animation?
User avatar
Justintime9
 
Posts: 1188
Joined: Sat Sep 29, 2007 5:37 am

Re: 2 buttons to the same animation

Postby D'Lanor » Sat Feb 06, 2010 9:25 am

No. That cannot be done with a quickscript. Not only does this require a full Alcscript but also a custom Python file. Though if you do it without SDL states you can skip the Python programming (but your age won't be multiplayer compatible).
"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: 2 buttons to the same animation

Postby J'Kla » Sat Feb 06, 2010 11:54 am

Make one button that is just bigger than the thickness of the wall then you can touch the same button from both sides. ;)
User avatar
J'Kla
 
Posts: 1003
Joined: Wed Feb 20, 2008 3:16 pm
Location: Geordieland UK

Re: 2 buttons to the same animation

Postby D'Lanor » Sat Feb 06, 2010 12:59 pm

J'Kla, that would still make the avatar do the button push animation on both sides of the door.

Justin, I believe this should do the trick. Use this AlcScript:
Code: Select all
AnimDoor:
    animations:
      - name: DoorAnim
        autostart: 0
        loop: 0
    logic:
        actions:
          - type: pythonfile
            tag: BoolTagResp
            pythonfile:
                file: ZeforaBoolTagResp
                parameters:
                  - type: string
                    value: DoorOpen
                  - type: responder
                    ref: $AnimFWOutside
                  - type: responder
                    ref: $AnimBWOutside
                  - type: bool
                    value: false
                  - type: bool
                    value: true
                  - type: string
                    value: inside
                  - type: responder
                    ref: $AnimFWInside
                  - type: responder
                    ref: $AnimBWInside
          - type: responder
            tag: AnimFWOutside
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:ButtonEmptyOutside
                            callbacks:
                              - marker: DoorButtonTouch
                                receiver: respondermod:$AnimFWOutside
                                user: 0
                        waiton: -1
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:AnimDoor
                            animname: DoorAnim
                            cmds:
                              - setforewards
                              - continue
                        waiton: 0
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:DoorCreakEmpty
                            cmds:
                               - play
                               - setvolume
                            volume: 1
                        waiton: -1
                    nextstate: 0
                    waittocmd: 0
                curstate: 0
                flags:
                  - detecttrigger
          - type: responder
            tag: AnimBWOutside
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:ButtonEmptyOutside
                            callbacks:
                              - marker: DoorButtonTouch
                                receiver: respondermod:$AnimBWOutside
                                user: 0
                        waiton: -1
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:AnimDoor
                            animname: DoorAnim
                            cmds:
                              - setbackwards
                              - continue
                        waiton: 0
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:DoorCreakEmpty
                            cmds:
                               - play
                               - setvolume
                            volume: 1
                        waiton: -1
                    nextstate: 0
                    waittocmd: 0
                curstate: 0
                flags:
                  - detecttrigger
          - type: responder
            tag: AnimFWInside
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:ButtonEmptyInside
                            callbacks:
                              - marker: DoorButtonTouch
                                receiver: respondermod:$AnimFWInside
                                user: 0
                        waiton: -1
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:AnimDoor
                            animname: DoorAnim
                            cmds:
                              - setforewards
                              - continue
                        waiton: 0
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:DoorCreakEmpty
                            cmds:
                               - play
                               - setvolume
                            volume: 1
                        waiton: -1
                    nextstate: 0
                    waittocmd: 0
                curstate: 0
                flags:
                  - detecttrigger
          - type: responder
            tag: AnimBWInside
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:ButtonEmptyInside
                            callbacks:
                              - marker: DoorButtonTouch
                                receiver: respondermod:$AnimBWInside
                                user: 0
                        waiton: -1
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:AnimDoor
                            animname: DoorAnim
                            cmds:
                              - setbackwards
                              - continue
                        waiton: 0
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:DoorCreakEmpty
                            cmds:
                               - play
                               - setvolume
                            volume: 1
                        waiton: -1
                    nextstate: 0
                    waittocmd: 0
                curstate: 0
                flags:
                  - detecttrigger


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

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

DoorButtonOutside:
    logic:
        modifiers:
          - tag: StateAnim
            cursor: poised
            flags:
              - localelement
            activators:
              - type: objectinvolume
                remote: ButtonRegionOutside
                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:$StateAnim
                  - type: string
                    value: DoorOpen
                  - type: skip
                  - type: skip
                  - type: string
                    value: outside

DoorButtonInside:
    logic:
        modifiers:
          - tag: StateAnim
            cursor: poised
            flags:
              - localelement
            activators:
              - type: objectinvolume
                remote: ButtonRegionInside
                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:$StateAnim
                  - type: string
                    value: DoorOpen
                  - type: skip
                  - type: skip
                  - type: string
                    value: inside

And make sure to replace the AlcScript for the AnimDoor object so that there are no double references to the same object. I gave the other objects different names to indicate their inside or outside position.

Then (assuming this is still Zefora) add this Python file to the pak of your age:
ZeforaBoolTagResp.zip
(2.19 KiB) Downloaded 242 times
"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: 2 buttons to the same animation

Postby J'Kla » Sat Feb 06, 2010 2:57 pm

But would it work if the animation was just the door opening so you could walk through?
User avatar
J'Kla
 
Posts: 1003
Joined: Wed Feb 20, 2008 3:16 pm
Location: Geordieland UK

Re: 2 buttons to the same animation

Postby D'Lanor » Sat Feb 06, 2010 4:06 pm

J'Kla wrote:But would it work if the animation was just the door opening so you could walk through?

Yes, in a sloppy kind of way. It still runs the responder twice but you would not notice that.
"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: 2 buttons to the same animation

Postby Justintime9 » Sat Feb 06, 2010 4:35 pm

Ok, I think I get that. Although the age isn't Zefora this time (probably should've mentioned that), it's Shinelight Manor (but the age file name is SparklingPalace). I would just change the name of the file, but I'm not sure if there's any more references to Zefora in there.

Also, When I copy and paste the AlcScript, (deleting the Quickscript I'm assuming), rather than it being pasted with it right up the the left side like it should, it's about 4 spaces too far to the right, and manually deleting it for the whole script could take awhile.
User avatar
Justintime9
 
Posts: 1188
Joined: Sat Sep 29, 2007 5:37 am

Re: 2 buttons to the same animation

Postby Chacal » Sat Feb 06, 2010 5:20 pm

Use a text editor and do a search-and-replace.
Chacal


"The weak can never forgive. Forgiveness is an attribute of the strong."
-- Mahatma Gandhi
User avatar
Chacal
 
Posts: 2515
Joined: Tue Nov 06, 2007 2:45 pm
Location: Quebec, Canada

Re: 2 buttons to the same animation

Postby D'Lanor » Sat Feb 06, 2010 5:38 pm

Do not use the forum's "Select All" function. That adds the extra 4 spaces.
"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: 2 buttons to the same animation

Postby Justintime9 » Sun Feb 07, 2010 6:13 am

Awesome :) that seems to have done the trick. Now just to clarify, will that be multiplayer compatible? I heard you mention that earlier, not sure what you meant.
User avatar
Justintime9
 
Posts: 1188
Joined: Sat Sep 29, 2007 5:37 am

Next

Return to Building

Who is online

Users browsing this forum: Google [Bot] and 5 guests