D'ni Musicbox

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

D'ni Musicbox

Postby Justintime9 » Sun Dec 13, 2009 9:50 am

I've modeled a D'ni musicbox, and want to make it operate like the musicbox on relto. Now, I have two sound emitters (one for the song it plays and one for the button push sound), but can't seem to find out how to trigger the sound by pushing the button. I assume it similar to the triggered animation quickscript, but how exactly would I get it to work like the one in relto?
User avatar
Justintime9
 
Posts: 1188
Joined: Sat Sep 29, 2007 5:37 am

Re: D'ni Musicbox

Postby diafero » Sun Dec 13, 2009 1:20 pm

The one in Relto also has the additonal feature of playing ogg files located in the "MyMusic" folder. I assume you could re-use the xMusicBox Python file, but I don't know how to write the AlcScript which would create the appropriate PythonFileMod.
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2966
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: D'ni Musicbox

Postby D'Lanor » Sun Dec 13, 2009 4:51 pm

Using xMusicBox.py would be needlessly complicated. And the method from Uru: CC won't be multiplayer compatible anyway. The MOUL version did make an (even more complicated) attempt at multiplayer compatibility but as I recall that didn't work out too well either.

So let's keep it simple :

Code: Select all
<clickable>:
    logic:
        modifiers:
          - cursor: poised
            flags:
              - localelement
            activators:
              - type: objectinvolume
                remote: <click region>
                triggers:
                  - any
            conditions:
              - type: activator
                activators:
                  - type: picking
              - type: objectinbox
                satisfied: true
            actions:
              - type: responder
                ref: $MusicBox
        actions:
          - type: responder
            tag: MusicBox
            responder:
                states:
                  - cmds:
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:<button emitter>
                            cmds:
                              - play
                              - setvolume
                            volume: 1
                        waiton: -1
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:<music emitter>
                            cmds:
                              - play
                              - setvolume
                            volume: 1
                        waiton: -1
                    nextstate: 1
                    waittocmd: 0
                  - cmds:
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:<button emitter>
                            cmds:
                              - play
                              - setvolume
                            volume: 1
                        waiton: -1
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:<music emitter>
                            cmds:
                              - stop
                        waiton: -1
                    nextstate: 0
                    waittocmd: 0
                curstate: 0
                flags:
                  - detecttrigger

(this isn't multiplayer compatible either but at least it is simple ;) )
"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: D'ni Musicbox

Postby Justintime9 » Sun Dec 13, 2009 6:44 pm

Awesome, I'll have to try that out. Only, why is "Button emitter" and "music emitter" in twice in the script?
User avatar
Justintime9
 
Posts: 1188
Joined: Sat Sep 29, 2007 5:37 am

Re: D'ni Musicbox

Postby D'Lanor » Sun Dec 13, 2009 7:03 pm

One click to start the music and one to stop it. That makes two.
"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: D'ni Musicbox

Postby J'Kla » Mon Dec 14, 2009 6:21 am

That has to be worth an audible Doh! :D
User avatar
J'Kla
 
Posts: 1003
Joined: Wed Feb 20, 2008 3:16 pm
Location: Geordieland UK

Re: D'ni Musicbox

Postby Justintime9 » Mon Dec 14, 2009 2:05 pm

:P I suppose I should learn to keep my mouth shut and insert the script as it is written.

Edit: Awesome, it works great! Now, how would I go about specifying what avatar animation it uses, and animating the musicbox button being pushed? Is there some way to fit the quickscripts animation script in there?
User avatar
Justintime9
 
Posts: 1188
Joined: Sat Sep 29, 2007 5:37 am

Re: D'ni Musicbox

Postby Trylon » Mon Dec 14, 2009 2:38 pm

Nah, no use using a script if you're not trying to understand it.
One day I ran through the cleft for the fiftieth time, and found that uru held no peace for me anymore.
User avatar
Trylon
 
Posts: 1446
Joined: Fri Sep 28, 2007 11:08 pm
Location: Gone from Uru

Re: D'ni Musicbox

Postby Justintime9 » Mon Dec 14, 2009 2:56 pm

Just because I can't write script backwards and forwards with my eyes closed doesn't mean I'm not trying. Cut me some slack here.
User avatar
Justintime9
 
Posts: 1188
Joined: Sat Sep 29, 2007 5:37 am

Re: D'ni Musicbox

Postby D'Lanor » Mon Dec 14, 2009 3:47 pm

Well, you didn't specify an avatar animation but somehow I expected that question. ;) The Relto music box uses the ButtonTouch animation.

Code: Select all
<clickable>:
    logic:
        modifiers:
          - cursor: poised
            flags:
              - localelement
            activators:
              - type: objectinvolume
                remote: <click region>
                triggers:
                  - any
            conditions:
              - type: activator
                activators:
                  - type: picking
              - type: objectinbox
                satisfied: true
            actions:
              - type: responder
                ref: $MusicBox
        actions:
          - type: responder
            tag: MusicBox
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:<oneshot empty name>
                            callbacks:
                              - marker: TouchButton
                                receiver: respondermod:$MusicBox
                                user: 0
                        waiton: -1
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:<button emitter>
                            cmds:
                              - play
                              - setvolume
                            volume: 1
                        waiton: 0
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:<music emitter>
                            cmds:
                              - play
                              - setvolume
                            volume: 1
                        waiton: -1
                    nextstate: 1
                    waittocmd:
                      - key: 0
                        msg: 0
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:<oneshot empty name>
                            callbacks:
                              - marker: TouchButton
                                receiver: respondermod:$MusicBox
                                user: 0
                        waiton: -1
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:<button emitter>
                            cmds:
                              - play
                              - setvolume
                            volume: 1
                        waiton: 0
                      - type: soundmsg
                        params:
                            receivers:
                              - 0011:<music emitter>
                            cmds:
                              - stop
                        waiton: -1
                    nextstate: 0
                    waittocmd:
                      - key: 0
                        msg: 0
                curstate: 0
                flags:
                  - detecttrigger


<oneshot empty name>:
    logic:
        actions:
          - type: oneshot
            name: <oneshot empty name>
            oneshot:
                animation: ButtonTouch


Edited script error!
Last edited by D'Lanor on Tue Dec 15, 2009 1:10 am, edited 1 time in total.
"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 0 guests

cron