GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Playing a sound/music from a variable label

helpingtogrowhelpingtogrow Posts: 27Member, PRO

Hi, I have a number of MP4 sound files loaded labelled eg. car, cat, dog etc.
How do I specify playing a sound file using a variable called e.g. CurrentLabel which is loaded with one of the sound labels eg. "cat"?
Thanks

Comments

  • tatiangtatiang Posts: 11,414Member, Sous Chef, PRO, Senior Sous-Chef

    You can't. I sure wish you could and people have asked for it but you can't. The best you can do is create a rule for every possible sound file you plan to use.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • helpingtogrowhelpingtogrow Posts: 27Member, PRO

    Is there an easy way to loop through the list to query the label and play the sound?

  • tatiangtatiang Posts: 11,414Member, Sous Chef, PRO, Senior Sous-Chef

    I'm not sure what you mean exactly but without attribute support for sound files, there's no way to automate this. You'll need a rule for each sound file. Ugh.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Twayne2Twayne2 Posts: 304Member, PRO

    What do you mean by variable?

  • tatiangtatiang Posts: 11,414Member, Sous Chef, PRO, Senior Sous-Chef

    @Twayne2 variable = attribute

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Twayne2Twayne2 Posts: 304Member, PRO

    So what is his question? I understand attributes can be used to play music.

  • tatiangtatiang Posts: 11,414Member, Sous Chef, PRO, Senior Sous-Chef
    edited September 13

    @Twayne2 said:
    So what is his question? I understand attributes can be used to play music.

    Can? How?

    One big change made to GameSalad was when the Change Scene behavior was altered so it included an expression editor. That allowed for dynamic selections of scenes instead of having to pick a scene from a drop-down menu.

    I believe @helpingtogrow wants the same option for Play Sound or Play Music: to be able to use an attribute/expression instead of a drop-down menu.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Twayne2Twayne2 Posts: 304Member, PRO

    Hm, I still don't get it. It isn't important for me though, I was just trying to understand what was going on. Thanks @tatiang. :grin:

  • tatiangtatiang Posts: 11,414Member, Sous Chef, PRO, Senior Sous-Chef
    edited September 13

    @Twayne2 Does this help?

    The current Play Music (or Play Sound) behavior looks like this:

    But what if you could choose a sound file based on an expression, like this*:

    So instead of having 30 different rules for 30 different sound files, you could accomplish the same thing with a single rule using attribute values, expression concatenation, etc.? Anyway, it would be WAY more efficient in terms of coding time.

    *Oops, I was rushing... it should have been "Level "..game.level.." complete" but whatever.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Twayne2Twayne2 Posts: 304Member, PRO

    Ok I get it now I think. Thanks.

Sign In or Register to comment.