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
For-loop - not declared [SOLVED]
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
For-loop - not declared [SOLVED]

Hey guys.

Take a look at this:

PHP Code: (Select All)
void CheckBattle()
{
    
//ENEMY//
    
    
for(int EnemyHealthCounter=EnemyMonsterHealth;EnemyHealthCounter<11;EnemyHealthCounter++)SetLampLit("EnemyHealth_"+EnemyHealthCounterfalse);
    
    
    
    
//FRIENDLY//
    
for(int FriendlyHealthCounter=FriendlyMonsterHealth;FriendlyHealthCounter<11;FriendlyHealthCounter++)SetLampLit("FriendlyHealth_"+FriendlyHealthCounterfalse);
    for(
int i=1;i<5;i++)SetEntityActive("Move_"+ifalse);
    
    
    
//MOVES//
    
for(int MoveCounter=1;MoveCounter<MoveAmount+1;MoveCounter++)SetEntityActive("Move_"+MoveCountertrue);
    
CreateParticleSystemAtEntity("MoveParticle_"+MoveCounter"ps_orb_absorb.ps""Move_"+MoveCounterfalse);
    
    
    if(
EnemyMonsterHealth <= 0)
    {
        
BattleEnd();
    }
    


I hope this lines up correctly.


It says EnemyMonsterHealth is not declared.

When I am clearly declaring it here:

PHP Code: (Select All)
void BattlePreparation()
{
    
SetLocalVarInt("InBattle"1);
    
    
//ENEMY MONSTER//
    
int EnemyMonsterHealth 10;
    
    
int MonsterNumber RandInt(1,2);
    
SetEntityActive("MonsterBox_"+MonsterNumbertrue);
    
    
    
CheckBattle();


What I'm trying to do is make a for loop check how much health the monster has by grabbing the actual health as the lowest and the max health (+1) as the highest.

Am I doing something wrong?

Trying is the first step to success.
(This post was last modified: 08-22-2014, 07:39 PM by FlawlessHappiness.)
08-22-2014, 06:23 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#2
RE: For-loop - not declared

I don't think the script can find the int variable there, considering it's not a global int either. I would put the int variable in the CheckBattle script as well.

void CheckBattle()
{
    //ENEMY//
    
     int EnemyMonsterHealth = 10;
for(int EnemyHealthCounter=EnemyMonsterHealth;EnemyHealthCounter<11;EnemyHealthCounter++)SetLampLit("EnemyHealth_"+EnemyHealthCounter, false);
    
    
    
    //FRIENDLY//
    for(int FriendlyHealthCounter=FriendlyMonsterHealth;FriendlyHealthCounter<11;FriendlyHealthCounter++)SetLampLit("FriendlyHealth_"+FriendlyHealthCounter, false);
    for(int i=1;i<5;i++)SetEntityActive("Move_"+i, false);
    
    
    //MOVES//
    for(int MoveCounter=1;MoveCounter<MoveAmount+1;MoveCounter++)SetEntityActive("Move_"+MoveCounter, true);
    CreateParticleSystemAtEntity("MoveParticle_"+MoveCounter, "ps_orb_absorb.ps", "Move_"+MoveCounter, false);
    
    
    if(EnemyMonsterHealth <= 0)
    {
        BattleEnd();
    }
    
}

Derp.
08-22-2014, 06:41 PM
Find
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#3
RE: For-loop - not declared

An int dies after it's functions is done. You need to use SetLocalVarInt("EnemyMonsterHealth);

Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
08-22-2014, 06:45 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: For-loop - not declared

Putting it there isn't gonna help much, since CheckBattle is actually checking the value of that int and if CheckBattle sets it to 10 all the time, there's no reason to check it..


I'm gonna try to fix this with a timer. Got other solutions? They'll be accepted with smiles ^^

(08-22-2014, 06:45 PM)Wapez Wrote: An int dies after it's functions is done. You need to use SetLocalVarInt("EnemyMonsterHealth);

Woop woop thanks! I'll see how it works!



EDIT: Oh god... It was too simple...

Thanks Wapez you solved one part.

The other part was... I need to remember to use GetLocalVarInt and not just use the name of the variable.

Trying is the first step to success.
(This post was last modified: 08-22-2014, 07:02 PM by FlawlessHappiness.)
08-22-2014, 06:46 PM
Find




Users browsing this thread: 1 Guest(s)