Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Music Throttle Based on Distance from Entity. It works! Sort of...

Author
Message
Ekipshi
15
Years of Service
User Offline
Joined: 20th May 2009
Location:
Posted: 14th Feb 2013 20:29
So.. I tried whipping up a script that would control the volume of the music depending on my distance from the entity who possesses the script.

But it only HALF works

I'm not entirely sure why, but it only works one way.

I start out far away from the entity, and it indeed immediately sets the music volume down. However, it does not increment up to full strength, instead immediately hitting 100 when I get RIGHT up to the entity.

NOW! When I start walking away from it, it DOES decrement gradually the further I get away..

Can anyone lend me a little insight as to why this might be the case?




Thank you!

Akanto10
14
Years of Service
User Offline
Joined: 24th Apr 2010
Location: Earth
Posted: 15th Feb 2013 02:56
I believe I see a small mistake in your snippet. However, you may want to use my version of your script, which is, in fact, very similar, but uses a different method of changing the music volume in a way that may save RAM consumption in your level.



I hope this helps,
Akanto

Ekipshi
15
Years of Service
User Offline
Joined: 20th May 2009
Location:
Posted: 16th Feb 2013 00:12
Thanks for having a look-see. It's... going to take me a bit to actually figure out how your script works.

Did you just whip that up or have you had that for a while?

There are many ways I can emulate the effect including the script you posted, but I still want to know why? Why does it work, why does mine not?

As well as (pardon my ignorance) how is it that yours uses less RAM, as it seems to throw in variables along side the states?

Akanto10
14
Years of Service
User Offline
Joined: 24th Apr 2010
Location: Earth
Posted: 16th Feb 2013 03:57
I had just made it right on the spot, actually. I believe that the reason why your script wouldn't work is because you didn't start at 2000 units or further away from the entity, which is equal to 20 segment spaces. Therefore, the music starts louder than you want it to. My script is designed to detect your distance and classify it as a certain level, which is passed on to a variable to detect any distance change. The reason it consumes less RAM is because FPSC runs scripts constantly, reading each line and executing it if it returns true. Therefore, when you have a line like the one below, FPSC constantly is setting the music volume over and over until you aren't further than 100 units. My script, on the other hand, will not repeat the "musicvolume=X" command unless there is a change in distance level.



I hope that clears everything up.

Thanks,
Akanto

Login to post a reply

Server time is: 2024-11-23 17:26:00
Your offset time is: 2024-11-23 17:26:00