stopwatch on loading.c

rafhot

Member
hi, im trying to create a kind of stopwatch to count the time my loading game are taking and also check if it happen some kind of mini freeze while it is loading
but im a little ruseted to make the script work im missing something

Code:
void main()
{
	void	s;
	void	value	=	getlocalvar("value");
	void	max		=	getlocalvar("max");
	
	void minutes=getlocalvar("minutes"), seconds=getlocalvar("seconds"), millisec=getlocalvar(" millisec");
	
	 
	
	
	
	
	

	
	
	
	
	
	
	if(max==1){
		return;
	}else{}

	void percent=value*100/max;
	percent%=++percent;

	void dot=percent%3;
	if(dot==0)
		s=".";
	else if(dot==1)
		s="..";
	else
		s="...";

	drawstring(450,93,4,"WARNING");
	drawstring(400,160,4,"THIS GAME IS NOT");
	drawstring(200,200,4,"PRODUCED UNDER LICENCE OF CAPCOM AND MARVEL");
	drawstring(324,340,4,"this game is a free fan game");
	drawstring(386,490,0,"Loading Models..."+percent);
	drawstring(510,490,0,"% Complete"+s);
	//drawbox(0,260,480,2,11,rgbcolor(0,122,133),0);
	//drawbox(0,260,percent*480*0.01,2,15,rgbcolor(0,233,233),0);
	
		while(max==99)
    {
        
                
                //Sleep(10);
                millisec++;
                if(millisec == 100)
                {
                    millisec = 0;
                    seconds++;
                    if(seconds == 60)
                    {
                        seconds = 0;
                        minutes++;
                    }
                }
			drawstring(450,70,0,"load timer test  "+minutes +seconds +millisec);	
				
	}			
                
	
	
	
	
	
	
	
	
}
 
Hmmm... I don't see anything which relates to time in the code
Anyways, I don't have mod with long loading time make it hard to test the code. But I can use update.c to test timer

I haven't made any scripts for this but I can tell you that if everytime openborvariant("elapsed_time") has reached 200 units, 1 second has passed. You can use that as reference
 
I've tried making stopwatch myself and here's the result:
Code:
void main()
{
        int LTime = getglobalvar("LTime");
        int Sekon; int Mili; int Menit;

        if(LTime == NULL()){
          LTime = 0;
        }

        Mili = (LTime/2)%100;
        Sekon = ((LTime/2)-Mili)/100;
        Menit = Sekon/60;

        if(Sekon >= 60){
          Sekon = Sekon-60;
        }

        drawstring(220,50,4, Menit+":"+Sekon+"."+Mili);

        setglobalvar("LTime", LTime+1);
}

Mili is not millisecond, it's centisecond actually
You can adjust text's placement, used font and display order yourself :)
 
BB, sorry to bring bad news, but the codes give a false impression that it works :(

If you test any build with the lag issue, you will noticed the counter doesn't reflects the actual time.
It woks on normal builds.

Also, since its not using a real timer, the variable increase will only work when the engine updates - and if the engine is locked on the delay as it is in the last builds, the variable won't be increased.
I tried my game on a working build and the meter said 0:13 seconds. Then I tried on a lagging build and the better said 0:14, when it tooks more than 1:00 to load. Plus, the stage load still use that variable and you will see a sum of the values and not a new count.
 
I know that, until we have a way to acquire CPU's timer, we won't be able to get real timer  :(
As for stage loading still using that variable, that can be solved by clearing "LTime" global variable in menu and level
 
Bloodbane said:
I know that, until we have a way to acquire CPU's timer, we won't be able to get real timer  :(

Getting system clock is easy... when one exists. Problem is that some platforms simply don't have one available, so the code wouldn't be portable at all.
 
Back
Top Bottom