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
Help ! Using variables (SOLVED)
Darkfire Offline
Senior Member

Posts: 371
Threads: 22
Joined: May 2014
Reputation: 15
#1
Help ! Using variables (SOLVED)

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//
}
}
(This post was last modified: 09-17-2014, 09:08 PM by Darkfire.)
05-21-2014, 08:13 PM
Find
Traggey Offline
is mildly amused

Posts: 3,257
Threads: 74
Joined: Feb 2012
Reputation: 185
#2
RE: Help ! Using variables

Wrong forum, moved.
05-21-2014, 08:36 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#3
RE: Help ! Using variables

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: (Select All)
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.

(This post was last modified: 05-21-2014, 08:44 PM by Mudbill.)
05-21-2014, 08:44 PM
Find
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#4
RE: Help ! Using variables

(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??
05-22-2014, 11:08 AM
Find
Darkfire Offline
Senior Member

Posts: 371
Threads: 22
Joined: May 2014
Reputation: 15
#5
RE: Help ! Using variables

(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: (Select All)
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.
05-22-2014, 02:22 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#6
RE: Help ! Using variables

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.

05-22-2014, 03:20 PM
Find
Darkfire Offline
Senior Member

Posts: 371
Threads: 22
Joined: May 2014
Reputation: 15
#7
RE: Help ! Using variables

(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 !
05-22-2014, 03:44 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#8
RE: Help ! Using variables

(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++.

"Veni, vidi, vici."
"I came, I saw, I conquered."
05-22-2014, 03:56 PM
Find




Users browsing this thread: 1 Guest(s)