|
Post by MonstaWolf on Oct 14, 2015 15:11:21 GMT
I'm having internet troubles right now, forgive me if this gets placed somewhere other than scripts for some reason. I'm having trouble getting a script to work. It's supposed to amplify the volume of the soundsource attached (OBJ_0) but even when I fix the errors, nothing happens. I can't find the script reference sheet anywhere, so that doesn't help. I can't place it in a code box, so if someone could put it in one that would help. Here it is:
(iKeyDown(iKeyCode("DIK_A")))
|
|
|
Post by Power Supersport on Oct 14, 2015 16:46:25 GMT
Ok... I'm gonna upload the script object reference since it's no longer available on the internet...
the way that you have to use this function is simple...
float volume; void Main () {
// Increase Volume if (iKeyDown(iKeyCode("DIK_A"))) { volume += 0.01; }
// Decrease Volume else if (iKeyDown(iKeyCode("DIK_Z"))) { volume -= 0.01; }
if (volume >= 1) volume = 1; if (volume <= 0) volume = 0;
OUT_1 = volume; // OUT_1 is the output of the sound object's volume }
|
|
|
Post by MonstaWolf on Oct 14, 2015 18:13:27 GMT
Ok... I'm gonna upload the script object reference since it's no longer available on the internet... the way that you have to use this function is simple... float volume; void Main () {
// Increase Volume if (iKeyDown(iKeyCode("DIK_A"))) { volume += 0.01; }
// Decrease Volume else if (iKeyDown(iKeyCode("DIK_Z"))) { volume -= 0.01; }
if (volume >= 1) volume = 1; if (volume <= 0) volume = 0;
OUT_1 = volume; // OUT_1 is the output of the sound object's volume } Ok, thanks. I will use that later, and will tell you how it went.
|
|
|
Post by MonstaWolf on Oct 14, 2015 18:49:21 GMT
So, I'm looking for a reference that makes it so that when you let go of A the sound goes quiet. I'm thinking the logic would go like this:
If A is being pressed down, the sound gets louder.
Otherwise, if A isn't being pressed, remain how it once was.
|
|
|
Post by Power Supersport on Oct 14, 2015 19:09:54 GMT
It's even simpler...
float volume; void Main () {
if (iKeyDown(iKeyCode("DIK_A"))) { volume = 1; // The power of the sound... } else { volume = 0; }
OUT_1 = volume; }
|
|
|
Post by MonstaWolf on Oct 14, 2015 19:11:30 GMT
Ah, that's what I thought, but I figured I'd ask you first
|
|
|
Post by Power Supersport on Oct 14, 2015 19:16:58 GMT
Well, no problem... I'm here to help... Always enjoying when there are questions and I can answer on something...
|
|
|
Post by MonstaWolf on Oct 14, 2015 23:46:45 GMT
So, I tried editing the script further to use iObjectRefresh to give a different sound to the SoundSource, but now I'm not hearing anything from it, but yet I get no errors. I copied and pasted the file paths directly, btw. Sorry if I seem noobish for asking tons of questions.
The not-working script (yet it has no errors in it):
float volume; void Main () {
if (iKeyDown(iKeyCode("DIK_A"))) { volume = 1; iObjectRefresh(OBJ_0,".\\3DRad_res\objects\SoundSource\data\ffrskb_up.wav"); } else { volume = 0.7; iObjectRefresh(OBJ_0,".\\3DRad_res\objects\SoundSource\data\ffrskb_rollin.wav"); }
OUT_1 = volume; }
|
|
|
Post by Power Supersport on Oct 15, 2015 15:17:26 GMT
Try this:
float volume; int time; void Main () {
if (iKeyDown(iKeyCode("DIK_A"))) { time += 1; if (time == 1) { volume = 1; // The power of the sound... iObjectRefresh(OBJ_0,".\\3DRad_res\\objects\\SoundSource\\data\\ffrskb_up.wav"); } } else { time = 0; volume = 0; iObjectRefresh(OBJ_0,".\\3DRad_res\\objects\\SoundSource\\data\\ffrskb_rollin.wav"); }
OUT_1 = volume; }
|
|
|
Post by MonstaWolf on Oct 15, 2015 16:16:48 GMT
Ah, I'll try to use that integer thing often then. Thanks for the help, I'll tell you if it worked or not.
|
|
|
Post by MonstaWolf on Oct 15, 2015 16:32:47 GMT
The sound cuts out when you let go of A, and comes back when you press it again. I tried messing with the volume and stuff, but nothing would work, even when I switched up the sounds. So, the sound works when you're holding down A, but doesn't when you let go. And, yes, the file paths are correct, as it worked when I swapped the sounds. I'll try to work on it a bit more to see if I can figure out the problem. Meanwhile I tried this, but that didn't work either float volume;
int time;
void Main () {
if (iKeyDown(iKeyCode("DIK_A"))) {
time += 1;
if (time == 1) {
volume = 1; // The power of the sound...
iObjectRefresh(OBJ_0,".\\3DRad_res\\objects\\SoundSource\\data\\ffrskb_up.wav");
}
}
else {
time = 0;
volume = 1.1;
if (time == 0) {
iObjectRefresh(OBJ_0,".\\3DRad_res\\objects\\SoundSource\\data\\ffrskb_rollin.wav");
}
}
OUT_1 = volume;
}
|
|
|
Post by Power Supersport on Oct 15, 2015 17:07:17 GMT
Ok... I will wait...
|
|
|
Post by MonstaWolf on Oct 15, 2015 18:58:28 GMT
Ok... I will wait... I just can't get it right... I don't know what else to try.
|
|