Frictional Games Forum (read-only)
Help ! Using variables (SOLVED) - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Help ! Using variables (SOLVED) (/thread-25342.html)



Help ! Using variables (SOLVED) - Darkfire - 05-21-2014

Hey ! I'm making a level in which I want at first to have lots (302!) of fog particles, and later rain particles. The second part works fine, but for some reason I can't delete these fog particles. Also, running the map doesn't end with a crash. Here's what I came up with:

void OnEnter()
{

SetLocalVarInt("FogVar", 0);


if(GetGlobalVarInt("RainVariable") > 0) ///this is a trigger, the variable is added in a different level///
{

if(GetLocalVarInt("FogVar") < 302)
{
AddLocalVarInt("FogVar", 1);
DestroyParticleSystem("ParticleSystem_" + GetLocalVarInt("FogVar"));
}
///here's stuff that makes the rain happen//
}
}


RE: Help ! Using variables - Traggey - 05-21-2014

Wrong forum, moved.


RE: Help ! Using variables - Mudbill - 05-21-2014

Well, the function doesn't repeat because it is only called once. You enter the level, 1 particle system is removed, and then the script is finished. You need something to recall this script.

I recommend using a for-loop instead. They're quite simple, really.

PHP Code:
for(int i 0302; ++i) {
    
DestroyParticleSystem("ParticleSystem_" i);


This will probably have the effect you want. It repeats the destroy script 302 times, each time incrementing the number at the end of the particle name.


RE: Help ! Using variables - DnALANGE - 05-22-2014

(05-21-2014, 08:36 PM)Traggey Wrote: Wrong forum, moved.

In stead of Always MOVED MOVED, i guess about 2500 posts are that.
Help this guy! AND other people..
You see the post then it is 30 seconds to help??


RE: Help ! Using variables - Darkfire - 05-22-2014

(05-21-2014, 08:44 PM)Mudbill Wrote: Well, the function doesn't repeat because it is only called once. You enter the level, 1 particle system is removed, and then the script is finished. You need something to recall this script.

I recommend using a for-loop instead. They're quite simple, really.

PHP Code:
for(int i 0302; ++i) {
    
DestroyParticleSystem("ParticleSystem_" i);

Thanks, it actually worked. Just one tiny downside: the particles load for one "animation" and then they disappear. I think I can't fix that (Since particles are in the level when it starts), but it isn't so bad.

Is there some page with for-loops tutorial ? Because I can't find one D:

Ps. Huge thanks Mudbill, I actually learned most of scripting stuff from your videos.


RE: Help ! Using variables - Mudbill - 05-22-2014

Well, you can always google for-loops for C++ Tongue
They work the same. This one might be good to read, as long as you can separate the cout << C++ syntax from Amnesia's.


RE: Help ! Using variables - Darkfire - 05-22-2014

(05-22-2014, 03:20 PM)Mudbill Wrote: Well, you can always google for-loops for C++ Tongue
They work the same. This one might be good to read, as long as you can separate the cout << C++ syntax from Amnesia's.

I think I get this now. I also used it to shorten my script in few places. PROBLEM SOLVED !


RE: Help ! Using variables - PutraenusAlivius - 05-22-2014

(05-22-2014, 02:22 PM)Darkfire Wrote: Is there some page with for-loops tutorial?

Here's a page about For loops and all other loops available in AngelScript and C++.