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
How to determine when for-loop is done
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#11
RE: How to determine when for-loop is done

Thank you for the explanation Cthulu!
I already knew about for-loops in general, but extra knowledge is always good.

I used the help I got to create this script:
PHP Code: (Select All)
int Spawn_PickUnusedNumber(string &in asNameint alFromint alTo)
{
    
int Start RandInt(alFrom,alTo);
    
int End alTo;
    
    for(
int i=Start;i<=End;i++)
    {
        if(
GetLocalVarInt(asName+i) == 0)
        {
            return 
int(i);
        }
    }
    
    return 
int(-1);


The idea is, I have a set of enemies. When one is spawned it's variable is set to 1. This is so that it cannot be picked while it is already active.

This Spawn_PickUnusedNumber helps me pick a number that isn't already used. If all numbers are used it'll set the number to -1, and thus...
PHP Code: (Select All)
if(iEnemy == -1)
    {
        
AddDebugMessage("ENEMY NOT FOUND"false);
        return;
    } 
...ignores this spawn.

Trying is the first step to success.
06-16-2015, 02:36 PM
Find


Messages In This Thread
RE: How to determine when for-loop is done - by FlawlessHappiness - 06-16-2015, 02:36 PM



Users browsing this thread: 1 Guest(s)