Playing a sound/music from a variable label

helpingtogrowhelpingtogrow Member, PRO Posts: 74

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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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 Member, PRO Posts: 74

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

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

    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 Member Posts: 458

    What do you mean by variable?

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

    @Twayne2 variable = attribute

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

  • Twayne2Twayne2 Member Posts: 458

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited September 2018

    @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 Member Posts: 458

    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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited September 2018

    @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 Member Posts: 458

    Ok I get it now I think. Thanks.

Sign In or Register to comment.