Setting a Slider's Value to an Int (SOLVED)

Started by R4L, Sat 23/12/2006 03:29:14

Previous topic - Next topic

R4L

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:

Code: ags

//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.

monkey0506

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:

Code: ags
int player_inwater =1;
int player_air = 100;


Lines outside of rep_ex.

strazer

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.

R4L

#3
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.  :)

SMF spam blocked by CleanTalk