User Tag List

Results 1 to 8 of 8

Thread: int[x] Checks Bug? (Or maybe just not wrote up yet?)

  1. #1
    Admiral Zim's Avatar
    Join Date
    Oct 2012
    Posts
    388
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    1,702
    Level
    13
    vBActivity - Bars
    Lv. Percent
    83.8%

    Not A Bug int[x] Checks Bug? (Or maybe just not wrote up yet?)

    For some reason or another when I converted my massive calculator script into int[24] format instead of 25 separate integers, the script cannot do the checks.
    Code:
    if(N[0]==0&&N[1]==0&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){PB();return;}
    Does not work, for example...
    Whereas
    Code:
    if(N==0&&oK==0&&oM==0&&oB==0&&oT==0&&kN==0&&kK==0&&kM==0&&kB==0&&kT==0&&mN==0&&mK==0&&mM==0&&mB==0&&mT==0&&bN==0&&bK==0&&bM==0&&bB==0&&bT==0&&tN==0&&tK==0&&tM==0&&tB==0&&tT==0){PB();return;}
    activated the PB() function just fine.
    I don't know if this is a bug or something that ZC is just not capable of doing.. It's essentially the exact same thing, except one is 25 checks to the same array, and the other is 25 separate integers.
    It would help out my game development very much to be able to do this check with one array instead of 25 separate integers!
    Thanks for all your years of work into this already!

  2. #2
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    37
    Posts
    4,436
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,563
    Level
    30
    vBActivity - Bars
    Lv. Percent
    52.05%
    Quote Originally Posted by Zim View Post
    For some reason or another when I converted my massive calculator script into int[24] format instead of 25 separate integers, the script cannot do the checks.
    Code:
    if(N[0]==0&&N[1]==0&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){PB();return;}
    Does not work, for example...
    That is almost unreadable. Do something like this instead:
    Code:
    if(Ncheck()) PB();
    
    //function that checks N[] array
    bool Ncheck()
    {
        for(int i; i < 25; i++){
            //if value is 0 keep going
            if(N[i] == 0) continue;
    
            //if not zero end function
            return false;
        }
        //all values are 0 so return true
        return true;
            
    }
    I use arrays like this and never have a problem. Double check the rest of your script and make sure nothing is saving data to the array and that the array is set up right.

    EDIT: I copied the code you said didn't work(the condition of the if) and put it in a script that plays a sound if the condition is true and it worked fine. Something else in your script is going wrong.
    Code:
    int N[25];
    
    global script test
    {
    	void run()
    	{
    		while(N[0]==0&&N[1]==0&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){
    			Game->PlaySound(23);
    			Waitframe();
    		}
    	}
    }

  3. #3
    Admiral Zim's Avatar
    Join Date
    Oct 2012
    Posts
    388
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    1,702
    Level
    13
    vBActivity - Bars
    Lv. Percent
    83.8%
    [QUOTE=SUCCESSOR;893198]That is almost unreadable. Do something like this instead:
    Code:
    if(Ncheck()) PB();
    
    //function that checks N[] array
    bool Ncheck()
    {
        for(int i; i < 25; i++){
            //if value is 0 keep going
            if(N[i] == 0) continue;
    
            //if not zero end function
            return false;
        }
        //all values are 0 so return true
        return true;
            
    }
    I can't do it like that because there's like 30 lines of code afterward that are the same thing but checking each one is >0...
    Code:
    if(mA && Cal==true)
    	{time+=15;
    	//This script block determines what happens to the numbers as the buttons are pressed on the keypad.
    	if(N[0]==0&&N[1]==0&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){PB();return;}
    	if(N[0]>0&&N[0]<10&&N[1]==0&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[0]=N[0]*10;PB();return;}
    	if(N[0]>=10&&N[0]<100&&N[1]==0&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[0]=N[0]*10;PB();return;}
    	if(N[0]>=100&&N[1]==0&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[1]=(N[0]-N[0]%100)/100;N[0]=(N[0]-(N[0]-N[0]%100))*10;PB();return;}
    	if(N[1]>0&&N[1]<10&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[1]=N[1]*10;N[1]+=(N[0]-N[0]%100)/100;N[0]=(N[0]-(N[0]-N[0]%100))*10;PB();return;}
    	if(N[1]>=10&&N[1]<100&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[1]=N[1]*10;N[1]+=(N[0]-N[0]%100)/100;N[0]=(N[0]-(N[0]-N[0]%100))*10;PB();return;}
    	if(N[1]>=100&&N[2]==0&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[2]=(N[1]-N[1]%100)/100;N[1]=(N[1]-(N[1]-N[1]%100))*10+(N[0]-N[0]%100)/100;N[0]=(N[0]-(N[0]-N[0]%100))*10;PB();return;}
    	if(N[2]>0&&N[2]<10&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[2]=N[2]*10;N[2]+=(N[1]-N[1]%100)/100;N[1]=(N[1]-(N[1]-N[1]%100))*10+(N[0]-N[0]%100)/100;N[0]=(N[0]-(N[0]-N[0]%100))*10;PB();return;}
    	if(N[2]>=10&&N[2]<100&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[2]=N[2]*10;N[2]+=(N[1]-N[1]%100)/100;N[1]=(N[1]-(N[1]-N[1]%100))*10+(N[0]-N[0]%100)/100;N[0]=(N[0]-(N[0]-N[0]%100))*10;PB();return;}
    	if(N[2]>=100&&N[3]==0&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[3]=(N[2]-N[2]%100)/100;N[2]=(N[2]-(N[2]-N[2]%100))*10+(N[1]-N[1]%100)/100;N[1]=(N[1]-(N[1]-N[1]%100))*10+(N[0]-N[0]%100)/100;N[0]=(N[0]-(N[0]-N[0]%100))*10;PB();return;}
    	if(N[3]>0&&N[3]<10&&N[4]==0&&N[5]==0&&N[6]==0&&N[7]==0&&N[8]==0&&N[9]==0&&N[10]==0&&N[11]==0&&N[12]==0&&N[13]==0&&N[14]==0&&N[15]==0&&N[16]==0&&N[17]==0&&N[18]==0&&N[19]==0&&N[20]==0&&N[21]==0&&N[22]==0&&N[23]==0&&N[24]==0){N[3]=N[3]*10;N[3]+=(N[2]-N[2]%100)/100;N[2]=(N[2]-(N[2]-N[2]%100))*10+(N[1]-N[1]%100)/100;N[1]=(N[1]-(N[1]-N[1]%100))*10+(N[0]-N[0]%100)/100;N[0]=(N[0]-(N[0]-N[0]%100))*10;PB();return;}
    }
    //and so on all the way to the last int[24]
    Is the whole part in question.
    It is a function that I wrote up to have a keypad be able to input numbers that moves the last digit over one place value every time a number is input on the keypad.
    There are other functions that change the data of the array, but that happens when someone presses the button, other than that, it stays as it is every frame, and every other function that uses those arrays is still working fine.

  4. #4
    Admiral Zim's Avatar
    Join Date
    Oct 2012
    Posts
    388
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    1,702
    Level
    13
    vBActivity - Bars
    Lv. Percent
    83.8%
    Code:
    bool MP(int tX,int tY,int upixels,int dpixels,int lpixels,int rpixels)
    	{if(tX+16+rpixels<=mX||tX-lpixels>=mX||tY+16+dpixels<=mY||tY-upixels>=mY){return false;}
    	if(tX+16+rpixels>mX&&tX-lpixels<mX&&tY+16+dpixels>mY&&tY-upixels<mY){return true;}}
    
    void PB() //Phone Buttons
    	{if(MP(100,100,1,0,1,0)==true){N[0]+=1;return;}if(MP(116,100,1,0,0,0)==true){N[0]+=2;return;}
    	if(MP(132,100,1,0,0,1)==true){N[0]+=3;return;}if(MP(100,116,0,0,1,0)==true){N[0]+=4;return;}
    	if(MP(116,116,0,0,0,0)==true){N[0]+=5;return;}if(MP(132,116,0,0,0,1)==true){N[0]+=6;return;}
    	if(MP(100,132,0,1,1,0)==true){N[0]+=7;return;}if(MP(116,132,0,0,0,0)==true){N[0]+=8;return;}
    	if(MP(132,132,0,1,0,1)==true){N[0]+=9;return;}
    	}
    Is the function that it calls, I see no errors with this scripting.. It just won't work on my game. See how the N[0] gets added the number the mouse is clicked on with the MP function over the area of the button 0-9.. This all worked just fine before I converted it to an array, and I made no mistakes in the conversion.. I can't see why it won't work other than I might've messed up my ZC by continuing the ZC game with new scripts or something..

  5. #5
    Admiral Zim's Avatar
    Join Date
    Oct 2012
    Posts
    388
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    1,702
    Level
    13
    vBActivity - Bars
    Lv. Percent
    83.8%
    I think I might've just learned what the problem is.. I wrote N[24] thinking that it automatically counted 0 in the amount of numerals instead of N[25] representing 25 numerals from 0-24. Thanks!

    Edit: Yes, that is exactly what my problem was. Thanks for your help!

  6. #6
    Admiral Zim's Avatar
    Join Date
    Oct 2012
    Posts
    388
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    1,702
    Level
    13
    vBActivity - Bars
    Lv. Percent
    83.8%
    Don't mean to be a bugger, but this topic should probably be deleted now since it's not actually a bug, rather than my lack of knowledge that led to this post.

  7. #7
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,826
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,959
    Level
    33
    vBActivity - Bars
    Lv. Percent
    26.2%
    A little late but you can avoid some things like this in the future by checking allegro.log for script errors/warnings.
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  8. #8
    Admiral Zim's Avatar
    Join Date
    Oct 2012
    Posts
    388
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    1,702
    Level
    13
    vBActivity - Bars
    Lv. Percent
    83.8%
    Quote Originally Posted by Gleeok View Post
    A little late but you can avoid some things like this in the future by checking allegro.log for script errors/warnings.
    Oh yeah.. I got so used to my scripts being written correctly I forgot about checking that often.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social