Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: R4L on Sat 23/12/2006 03:29:14

Title: Setting a Slider's Value to an Int (SOLVED)
Post by: R4L on Sat 23/12/2006 03:29:14
OK, Im using SimpleSnow 1.0 and I have this problem with a function that decrements a slider by 1 every 100 game cycles. I think they interfere since they both are repeatedly executed by rep_execute. Here is my code:


//in rep_execute

int counter = 0;
  int player_inwater = 1;
  int player_air = 100; 
 
if(player_inwater == 1){
if (counter < 99)
counter++;
else
{
player_air--;
sliderone.Value = player_air;
counter = 0;
}
}


Is this wrong?  ???

EDIT: Never mind, just had to use timers instead to bypass the Module's rep_execute function.
Title: Re: Slider Problem (SOLVED)
Post by: monkey0506 on Sat 23/12/2006 07:10:49
If you're actually defining your variables inside of rep_ex they 1) won't exist outside of rep_ex, and 2) will be initialized every time rep_ex is called (every game loop).

Move your:

int player_inwater =1;
int player_air = 100;


Lines outside of rep_ex.
Title: Re: Slider Problem (SOLVED)
Post by: strazer on Sat 23/12/2006 13:44:31
Right, you shouldn't need to "bypass the Module's rep_execute function". Every module, the global script and each room can have their own independent repeatedly_execute(_always) functions.
Title: Re: Slider Problem (SOLVED)
Post by: R4L on Sat 23/12/2006 18:00:01
I must have forgotten that you have to declare ints outside of functions. Thanks guys.  :)

EDIT: Never mind again. I had to declare it in my global script first.  :)