Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Sounds don't play
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#16
RE: Sounds don't play

(12-19-2012, 08:07 PM)TheGreatCthulhu Wrote: So, about using funcdefs instead - first you'd define a function handle type, like this:
funcdef void WindFunc();

This should be a global declaration (outside of any function).

Here, WindFunc is a function pointer type which can point to any function wich has the signature:
void SomeFuncName();

==> and your functions do, so they qualify:
void windysound_1 ()

Then you can declare (globally) an array of these function handles (function pointers):
WindFunc@[] functions(3); // declares an array of size 3

Next, in OnEnter(), you can assign the appropriate function to each member of the array:
@functions[0] = @windysound_1;
@functions[1] = @windysound_2;
@functions[2] = @windysound_3;


Finally, when the time comes, you can pick one randomly, and make the call, like this:
Action@ f = functions[RandInt(0, functions.length() - 1)];
f();


In the first line, RandInt(0, functions.length() - 1) randomly picks an index to some array member ( indices range from 0 to length-1). The resulting array member is assigned to the local variable f, and then in the next line, f is used to make the call to whichever of your windysound_#() functions got picked.

BTW, if it's easier to undersand, you can also write the same thing like this:

int maxValue = functions.length() - 1;
int index = RandInt(0, maxValue);
Action@ f = functions[index];
f();

TheGreatChtulhu, you have the sea of your mind filled with knowledge XD

Now, you seem a good scripter, but I'm not so that good. Can you please put me an example for this? It's just that I'm not familiar with this, you know? Oh, and thanks to take your time in helping me Smile

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
12-19-2012, 09:33 PM
Find


Messages In This Thread
Sounds don't play - by The chaser - 12-12-2012, 09:38 PM
RE: Sounds don't play - by Juby - 12-12-2012, 09:57 PM
RE: Sounds don't play - by The chaser - 12-12-2012, 10:15 PM
RE: Sounds don't play - by FlawlessHappiness - 12-12-2012, 10:45 PM
RE: Sounds don't play - by The chaser - 12-12-2012, 10:58 PM
RE: Sounds don't play - by FlawlessHappiness - 12-13-2012, 07:02 AM
RE: Sounds don't play - by The chaser - 12-13-2012, 07:48 AM
RE: Sounds don't play - by JMFStorm - 12-13-2012, 07:56 AM
RE: Sounds don't play - by The chaser - 12-13-2012, 10:17 AM
RE: Sounds don't play - by FlawlessHappiness - 12-13-2012, 10:50 AM
RE: Sounds don't play - by The chaser - 12-13-2012, 02:50 PM
RE: Sounds don't play - by TheGreatCthulhu - 12-17-2012, 01:40 PM
RE: Sounds don't play - by The chaser - 12-17-2012, 08:34 PM
RE: Sounds don't play - by TheGreatCthulhu - 12-19-2012, 10:02 AM
RE: Sounds don't play - by TheGreatCthulhu - 12-19-2012, 08:07 PM
RE: Sounds don't play - by The chaser - 12-19-2012, 09:33 PM
RE: Sounds don't play - by TheGreatCthulhu - 12-19-2012, 10:45 PM



Users browsing this thread: 5 Guest(s)