Help with "advanced widget script" - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: Help with "advanced widget script" (/thread-7854.html) |
Help with "advanced widget script" - Ge15t - 05-07-2011 Code: void OnStart() Ok so this is the the script that I want to play with the foot step noises, but i cant seem to get it working. Can someone help me out here? the footsteps file is scare_wood_creak_mix.snt. I just need some clearer instructions on what exactly the Code: (int s=1;s<11;s++) AddTimer("step"+s, 0.8 * s, "CreateFootstep"); RE: Help with "advanced widget script" - Apjjm - 05-07-2011 Code: for(int s=1;s<11;s++) AddTimer("step"+s, 0.8 * s, "CreateFootstep"); The loop there takes the following form: Code: for ( <1> ; <2> ; <3>) {<4> } In this case, we define an integer variable called "s" at the start of the loop. "s" is initialised to 1, and will increment by 1 (s++) whilst "s < 11". This means AddTimer(..) is called like so: Code: AddTimer("step"+1, 0.8 * 1, "CreateFootstep"); "CreateFootstep" creates a footstep sound in the code shown. Though note that the callback also has an argument which is the timer that actually called the function. This gives you the option to do something on a given footstep. E.g for the 2nd footstep, you could check if "asTimer" was equal to "step2", and perform the actions you wish to perform. RE: Help with "advanced widget script" - Ge15t - 05-08-2011 Ok so what about Code: void CreateFootstep(string &in asTimer) Ok so copy pasted straight from the adv script widgets page, Code: //make sure asTimer (the name of the timer which calls the CreateFootsteps function) MATCHES the area you want to play the step at. In this case, your areas MUST be named "step1", "step2", etc until you reach "step10", just as the timers are named "step1", "step2", etc. There are only 10 steps, because the for loop stops when s reaches 11. So for this bit, would I have to create 10 'areas' named step1, step2 etc which the function would call each at 0.8 seconds? And for the bit i put in bold, what is that?? And do I need Code: if(asTimer == "step2") This is honestly doing my head in lol. and steam isnt working atm so i cant test it out, but want to get it right. RE: Help with "advanced widget script" - Apjjm - 05-08-2011 Code: if(asTimer == "step2") Quote:So for this bit, would I have to create 10 'areas' named step1, step2 etc which the function would call each at 0.8 seconds? And for the bit i put in bold, what is that?? that function is of the following form: Code: //From the script functions page in the wiki: asEntity, is the place to play the footstep at - and set to "StartFootstepsArea". This means you only need one script area called "StartFootstepsArea". The last two arguments state a fade-in time (of 0) and whether the state of the sound should be saved. However, if you want to make it so you have 10 areas - one for each footstep, you can simply do the following: Code: PlaySoundAtEntity("scary"+asTimer, "scare_wood_creak_mix.snt", "Foot"+asTimer, 0, false); |