Accessing a second entry in a table to play a sound
DaveGWelsh
Member Posts: 60
Hi,
I ma working with tables at the moment whereby when an event is called, it selects a random item from a column and displays the text on-screen. This works fine, no problem at all. However, my issue at the moment is that I want it to play a specific sound at the same time; so if entry 1 was selected, it would play sound A, entry 3 would play sound C for example.
Does anyone have any suggestion how to go about this?
Many thanks in advance!
I ma working with tables at the moment whereby when an event is called, it selects a random item from a column and displays the text on-screen. This works fine, no problem at all. However, my issue at the moment is that I want it to play a specific sound at the same time; so if entry 1 was selected, it would play sound A, entry 3 would play sound C for example.
Does anyone have any suggestion how to go about this?
Many thanks in advance!
Comments
When attribute game.columnValue=1
Play sound [sound file A]
When attribute game.columnValue=2
Play sound [sound file B]
When attribute game.columnValue=3
Play sound [sound file C]
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
First, you may have to add a rule to your event where, along with displaying the text, you also set an attribute (integer) to whatever the random number chosen is. We will call this "random_item_number" for now...
Once you have an attribute that now will always contain the current "random" number, you could create an invisible actor (or just off-screen) that "watches" for this event you described above. Make rules on your new invisible actor that state:
"When 'random_item_number' = 0, DO NOTHING"
"When 'random_item_number' = 1, play sound XXXX and then Set 'random_item_number' back to 0"
"When 'random_item_number' = 2, play sound XXXX and then Set 'random_item_number' back to 0"
etc...
The "and then Set 'random_item_number' back to 0" is to prevent any sounds from being played more than once by accident.
NOTE - Technically, you would not need to actually have a rule stating to "DO NOTHING"... I just put that there for a reference. Whenever the attribute = 0, unless stated otherwise, it would "do nothing" anyway.
Does that make sense/help?
This approach was what I tried to do, however I can't seem to access the table value from the rule.
Is it actually possible?
Thanks!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User