User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 35

Thread: Checking for integers and floats....

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ultimate Prankster Lucario QDB Manager
    Just registered
    Nimono's Avatar
    Join Date
    Nov 2005
    Location
    Static Void Kingdom
    Age
    32
    Posts
    1,963
    Mentioned
    5 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    6,280
    Level
    24
    vBActivity - Bars
    Lv. Percent
    44.51%

    Checking for integers and floats....

    One final question from me! And please, don't ask me why I made a new thread...

    Okay, in my Cane of Somaria script, I've declared a variable called "SomariaCheck". Every time you change the settings of the combo two tiles away from you, a 1 is written to this variable. At the beginning of the script, it first checks for the solidity of the combo at the Block's position. If it comes back as 15 (in decimal- That'd be 1111 in binary, which is total solidity), it then checks the value of SomariaCheck. If it's a 1, it modifies the block to remove it and it then sets SomariaCheck to 0. The problem is, since I need to use that at the start of my script so it doesn't destroy a block right after I create one, I needed to declare that variable at runtime. Unfortunately, it seems to ignore that value. When I declare a variable in void run(), does it automatically set it to 0? If so, what can I do to avoid this? Telling me to not use another variable isn't going to work- I declare 4 variables at runtime- SomariaBlockX, SomariaBlockY, SomariaBlockPosition, and SomariaCheck. The first two are because I don't need to write anything to them at first. The second two are there because I use them both in the code for checking for a block. So, what's going on? Do those variables simply become 0 whenever the code ends? Would writing to d0-7 be better?

  2. #2
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,436
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.65%

    Re: Checking for integers and floats....

    If it comes back as 15 (in decimal- That'd be 1111 in binary, which is total solidity), it then checks the value of SomariaCheck. If it's a 1, it modifies the block to remove it and it then sets SomariaCheck to 0. The problem is, since I need to use that at the start of my script so it doesn't destroy a block right after I create one, I needed to declare that variable at runtime.
    Technically, you're declaring them well before run time.
    If you only need two different values, corresponding roughly to "yes" and "no," you might use a bool instead of a number. A bit more logical, and easier to change: you can just write SomariaCheck = !SomariaCheck; instead of going through an if/else or an equation. That's not too important, though.

    When I declare a variable in void run(), does it automatically set it to 0? If so, what can I do to avoid this?
    I don't know if it does, actually, but I don't see why it would matter. Not unless you're planning to use an uninitialized variable for something, which is pretty much never a good idea.
    If you're just trying to set the starting value, initialize it when you declare it, like this:
    Code:
    int x = 5;
    So, what's going on? Do those variables simply become 0 whenever the code ends? Would writing to d0-7 be better?
    Don't know. Probably not. But what difference does it make? If it's finished with the code, you can't use the variables anymore, anyway.
    You can't use d0-d7. There's no way to access them directly in ZScript.

  3. #3
    Ultimate Prankster Lucario QDB Manager
    Just registered
    Nimono's Avatar
    Join Date
    Nov 2005
    Location
    Static Void Kingdom
    Age
    32
    Posts
    1,963
    Mentioned
    5 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    6,280
    Level
    24
    vBActivity - Bars
    Lv. Percent
    44.51%

    Re: Checking for integers and floats....

    Quote Originally Posted by Saffith View Post
    Technically, you're declaring them well before run time.
    If you only need two different values, corresponding roughly to "yes" and "no," you might use a bool instead of a number. A bit more logical, and easier to change: you can just write SomariaCheck = !SomariaCheck; instead of going through an if/else or an equation. That's not too important, though.

    I don't know if it does, actually, but I don't see why it would matter. Not unless you're planning to use an uninitialized variable for something, which is pretty much never a good idea.
    If you're just trying to set the starting value, initialize it when you declare it, like this:
    Code:
    int x = 5;
    Don't know. Probably not. But what difference does it make? If it's finished with the code, you can't use the variables anymore, anyway.
    You can't use d0-d7. There's no way to access them directly in ZScript.
    It figures. :p

    So what exactly does SomariaCheck = !SomariaCheck; do, anyways? But wouldn't I still need to do an if statement? It's supposed to do one thing if it's equal to a certain thing and not do that if it's not equal. ...Oh well. You understand this more than me. :p

  4. #4
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,436
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.65%

    Re: Checking for integers and floats....

    Well, I'm assuming it's a bool there. Bools can be either true or false. The exclamation point is the NOT operator: !true is false, and !false is true. So, if SomariaCheck is a bool, that line has the same effect as this:
    Code:
    if(SomariaCheck == true) // You could also just write if(SomariaCheck)
       SomariaCheck = false;
    else
       SomariaCheck = true;
    That's only if it's a bool, though. You can't do that with numbers.

  5. #5
    Ultimate Prankster Lucario QDB Manager
    Just registered
    Nimono's Avatar
    Join Date
    Nov 2005
    Location
    Static Void Kingdom
    Age
    32
    Posts
    1,963
    Mentioned
    5 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    6,280
    Level
    24
    vBActivity - Bars
    Lv. Percent
    44.51%

    Re: Checking for integers and floats....

    So, let's say I was to do something like Link->InputUp = true. If I used SomariaCheck = !SomariaCheck, would it look like this:

    Code:
    SomariaCheck = !SomariaCheck;
    Link->InputUp = true;
    Or would I use something else? (Please bear with me- I'll remember this for a while once I get it, trust me.)

  6. #6
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,436
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.65%

    Re: Checking for integers and floats....

    I'm not certain I see what you're asking, but that bit of code looks perfectly fine.

  7. #7
    Keese
    Join Date
    Aug 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    834
    Level
    10
    vBActivity - Bars
    Lv. Percent
    10.31%

    Re: Checking for integers and floats....

    I wrote a variation of the script with a different function;

    Code:
    import "std.zh"
    item script Somaria{
    
    	int blockY = 0;
    	int blockX = 0;
    	int blockcombo = 0;
    	int blocksecrect = 0;
    	int blockCset = 0;
    	bool disapear = false;
    
    		void run()
    
    		int blockcheckY = 0;
    		int blockcheckX = 0;
    		float RmndrX = 0;
    		float RmndrY = 0;
    		float BlockrmndrX = 0;
    		float BlockrmndrY = 0;
    		int Blockposition = 0;
    
    			if (dispear == false){
    				
    				if (Link->Dir == 0){
    				blockcheckY = Link->Y - 32;
    				blockcheckX = Link->X;
    				RmndrX = blockcheckX % 16;
    	
    					if (RmndX <= 8){
                    			blockcheckX = blockcheckX - RmndrX;
                				}
                				else
                				{
                    			blockcheckX = blockcheckX + 16 - RmndrX;
                				}
                			
    					RmndrY = blockcheckY % 16;
                			
    					if (RmndrY <= 8){
                				{
                    			blockcheckY = blockcheckY - RmndrY;
                				}
                				else
                				{
                    			blockcheckY = blockcheckY + 16 - RmndrY;
               			 	}
    
    					if (ComboAt(blockcheckX, blockcheckY) == 0){
    					BlockrmndrX = blockX % 16;
    				
    					if (BlockrmndrX <= 8){
                    			blockX = blockX - BlockrmndrX;
                				}
                				else
                				{
                    			blockX = blockX + 16 - BlockrmndrX;
                				}
                				BlockrmndrY = blockY % 16;
    
                				if (BlockRmndrY <= 8){
                				{
                    			blockY = blockY - BlockrmndrY;
                				}
                				else
                				{
                    			blockY = blockY + 16 - BlockrmndrY;
               				}			
    					int Blockposition = (ComboAt(blockX, blockY))
    					Screen->ComboD [Blockposition] = blockcombo;
                    			Screen->ComboC [Blockposition] = blockCset;
                    			Screen->ComboF [Blockposition] = blocksecret;
                    			disapear = true;
    				}
    
    				if (Link->Dir == 1){
    				blockcheckY = Link->Y + 32;
    				blockcheckX = Link->X;
    				RmndrX = blockcheckX % 16;
    	
    					if (RmndX <= 8){
                    			blockcheckX = blockcheckX - RmndrX;
                				}
                				else
                				{
                    			blockcheckX = blockcheckX + 16 - RmndrX;
                				}
                			
    					RmndrY = blockcheckY % 16;
                			
    					if (RmndrY <= 8){
                				{
                    			blockcheckY = blockcheckY - RmndrY;
                				}
                				else
                				{
                    			blockcheckY = blockcheckY + 16 - RmndrY;
               			 	}
    
    					if (ComboAt(blockcheckX, blockcheckY) == 0){
    					BlockrmndrX = blockX % 16;
    				
    					if (BlockrmndrX <= 8){
                    			blockX = blockX - BlockrmndrX;
                				}
                				else
                				{
                    			blockX = blockX + 16 - BlockrmndrX;
                				}
                				BlockrmndrY = blockY % 16;
    
                				if (BlockRmndrY <= 8){
                				{
                    			blockY = blockY - BlockrmndrY;
                				}
                				else
                				{
                    			blockY = blockY + 16 - BlockrmndrY;
               				}			
    					int Blockposition = (ComboAt(blockX, blockY))
    					Screen->ComboD [Blockposition] = blockcombo;
                    			Screen->ComboC [Blockposition] = blockCset;
                    			Screen->ComboF [Blockposition] = blocksecret;
                    			disapear = true;
    				}
    
    
    				if (Link->Dir == 2){
    				blockcheckY = Link->Y;
    				blockcheckX = Link->X - 32;
    				RmndrX = blockcheckX % 16;
    	
    					if (RmndX <= 8){
                    			blockcheckX = blockcheckX - RmndrX;
                				}
                				else
                				{
                    			blockcheckX = blockcheckX + 16 - RmndrX;
                				}
                			
    					RmndrY = blockcheckY % 16;
                			
    					if (RmndrY <= 8){
                				{
                    			blockcheckY = blockcheckY - RmndrY;
                				}
                				else
                				{
                    			blockcheckY = blockcheckY + 16 - RmndrY;
               			 	}
    
    					if (ComboAt(blockcheckX, blockcheckY) == 0){
    					BlockrmndrX = blockX % 16;
    				
    					if (BlockrmndrX <= 8){
                    			blockX = blockX - BlockrmndrX;
                				}
                				else
                				{
                    			blockX = blockX + 16 - BlockrmndrX;
                				}
                				BlockrmndrY = blockY % 16;
    
                				if (BlockRmndrY <= 8){
                				{
                    			blockY = blockY - BlockrmndrY;
                				}
                				else
                				{
                    			blockY = blockY + 16 - BlockrmndrY;
               				}			
    					int Blockposition = (ComboAt(blockX, blockY))
    					Screen->ComboD [Blockposition] = blockcombo;
                    			Screen->ComboC [Blockposition] = blockCset;
                    			Screen->ComboF [Blockposition] = blocksecret;
                    			disapear = true;
    				}
    
    				if (Link->Dir == 3){
    				blockcheckY = Link->Y;
    				blockcheckX = Link->X + 32;
    				RmndrX = blockcheckX % 16;
    	
    					if (RmndX <= 8){
                    			blockcheckX = blockcheckX - RmndrX;
                				}
                				else
                				{
                    			blockcheckX = blockcheckX + 16 - RmndrX;
                				}
                			
    					RmndrY = blockcheckY % 16;
                			
    					if (RmndrY <= 8){
                				{
                    			blockcheckY = blockcheckY - RmndrY;
                				}
                				else
                				{
                    			blockcheckY = blockcheckY + 16 - RmndrY;
               			 	}
    
    					if (ComboAt(blockcheckX, blockcheckY) == 0){
    					BlockrmndrX = blockX % 16;
    				
    					if (BlockrmndrX <= 8){
                    			blockX = blockX - BlockrmndrX;
                				}
                				else
                				{
                    			blockX = blockX + 16 - BlockrmndrX;
                				}
                				BlockrmndrY = blockY % 16;
    
                				if (BlockRmndrY <= 8){
                				{
                    			blockY = blockY - BlockrmndrY;
                				}
                				else
                				{
                    			blockY = blockY + 16 - BlockrmndrY;
               				}			
    					Blockposition = (ComboAt(blockX, blockY))
    					Screen->ComboD [Blockposition] = blockcombo;
                    			Screen->ComboC [Blockposition] = blockCset;
                    			Screen->ComboF [Blockposition] = blocksecret;
                    			disapear = true;
    				}
    			}
    			else
    			{
    			Blockposition = (ComboAt(blockX, blockY))
    			Screen->ComboD [Blockposition] = 0;
                    	Screen->ComboF [Blockposition] = 0;
                    	disapear = false;
    			}
    		
    		} //End of void run
    
    } //End of Script
    The compiler gives me "Unexpected Identifier" at this part, and I have no idea why.

    Code:
    Screen->ComboD [Blockposition] = blockcombo;

  8. #8
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,436
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.65%

    Re: Checking for integers and floats....

    Because you forgot the semicolon on the line before.

  9. #9
    Ultimate Prankster Lucario QDB Manager
    Just registered
    Nimono's Avatar
    Join Date
    Nov 2005
    Location
    Static Void Kingdom
    Age
    32
    Posts
    1,963
    Mentioned
    5 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    6,280
    Level
    24
    vBActivity - Bars
    Lv. Percent
    44.51%

    Re: Checking for integers and floats....

    So, what exactly does THAT do, Fire Wizzrobe? What's its "different function"?

  10. #10
    Keese
    Join Date
    Aug 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    834
    Level
    10
    vBActivity - Bars
    Lv. Percent
    10.31%

    Re: Checking for integers and floats....

    Ooh. That's embarrassing.

    It also gives me "Unexpected End" at two lines after the end of the FFC script bracket.

    Pikaguy- It make appear and reappear by the swinging of the cane and does not go away when you leave the screen.

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