User Tag List

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

Thread: More Insane Script Problems!

  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,276
    Level
    24
    vBActivity - Bars
    Lv. Percent
    43.97%

    More Insane Script Problems!

    It's that time again....

    This time, I have problems working with parentheses. It's currently saying that void Quit() is wrong, because of the parentheses. The error it gives is:

    Syntax error, unexpected lparen, expecting assing, on token (.

    How is that wrong?! If I put a space so it looks like void Quit (), it's STILL wrong. So, in other words, it's saying that void Quit() isn't a valid arguement! What is going on here?

  2. #2
    Lynel Nick's Avatar
    Join Date
    Oct 2001
    Location
    I don't remember...
    Posts
    1,918
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,819
    Level
    17
    vBActivity - Bars
    Lv. Percent
    26.21%

    Re: More Insane Script Problems!

    Use ordinary "Quit();"

    void is the return type (or lack of return type) for a function you are creating. Quit is an already existing function, thus this is not necessary.

  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,276
    Level
    24
    vBActivity - Bars
    Lv. Percent
    43.97%

    Re: More Insane Script Problems!

    Quote Originally Posted by Nick View Post
    Use ordinary "Quit();"

    void is the return type (or lack of return type) for a function you are creating. Quit is an already existing function, thus this is not necessary.
    Oh. ....then why must I use void for run?....

    Edit: Gah, more problems. Thois time, it's problems casting float to bool..... and I'm having problems getting PlaySound to work. Do I need to use int, float, bool, or void before it?

  4. #4
    Lynel Nick's Avatar
    Join Date
    Oct 2001
    Location
    I don't remember...
    Posts
    1,918
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,819
    Level
    17
    vBActivity - Bars
    Lv. Percent
    26.21%

    Re: More Insane Script Problems!

    Because, you are defining run.

    PlaySound is another situation where there is no return type before it... because it's already defined. Essentially, any function that you actually put stuff within curly braces {} is a function you are defining on your own. These are the functions that require you to add the return type (void, int, whatever) at the beginning.

    PlaySound is actually initialized by using...
    Code:
    Game->PlaySound(sfx_slot)
    
    //sfx_slot is the slot of the sound effect.
    Most of the functions in the ZScript documentation outside of the global ones are accessable using pointers such as Game->, Link->, and such.

    If this next paragraph confuses you, completely ignore it since what I initially said applies to what you are currently doing. It's possible to call functions you defined on your own from other functions. An example of this would be...

    Code:
    ffc script NAME { 
    	
            void Hello() { // I am defining a function called Hello
                     // Do stuff
            } //! End of Hello function I defined
    
    
    	void run() { // I am defining the run() function. ZQuest looks for this and runs it first, always.
    	
    		while(true){ // Beginning of internal while loop. 
                            Hello(); // I am calling the Hello() function I defined.
    			Waitframe(); // This is a global command that doesn't require a pointer.
    		}//! End of internal while loop
    	} //! End of run function
    }//! End of ffc script

    As far as the bool casting error, I cannot really tell you anything with so little info about what the script is actually doing.

  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,276
    Level
    24
    vBActivity - Bars
    Lv. Percent
    43.97%

    Re: More Insane Script Problems!

    XD I knew I'd get that response. Umm.... The script is a Shovel script. The way I see it, the Shovelis simply a modfied Cane of Somaria, because both spawn a combo in place of another. So far, I've made tiny modifications to the Cane of Somaria script to get the Shovel. Here's what I have now, thanks to you:

    Code:
    // Shovel- Well, what do you THINK it does? :P It digs up the ground directly in front of you,
    // provided it's not solid or a certain combo. The combos it can't dig up are yours to decide!
    // However, I give you three solid combos it CAN dig up, so use them wisely.
    // Variables:
    // ComboDug- Combo that appears when you dig in a diggable spot.
    // Combo1- First Combo you can't dig in.
    // Combo2- 2nd Combo you can't dig in.
    // Combo3- 3rd No-Dig Combo.
    // Combo4- 4th No-Dig Combo.
    // Combo5- 5th No-Dig Combo.
    // ComboS1- First Solid Combo you can dig in.
    // ComboS2- 2nd Solid Dig Combo.
    // ComboS3- 3rd Solid Dig Combo.
    
    import "std.zh"
    item script Shovel
    {
    	int ComboDug = 0;
    	int Combo1 = 0;
    	int Combo2 = 0;
    	int Combo3 = 0;
    	int Combo4 = 0;
    	int Combo5 = 0;
    	int ComboS1 = 0;
    	int ComboS2 = 0;
    	int ComboS3 = 0;
    	int ComboX = 0;
    	int ComboY = 0;
    	int ComboSDug = 0;
    
    	void run()
    	{
    		if (Link->Dir == 0)
    		{
    			int BlockCheckY = Link->Y - 16;
    			int BlockCheckX = Link->X;
    			float BlockRmndrX = BlockCheckX % 16;
    			if (BlockRmndrX <= 8)
    			{
    				BlockCheckX = BlockCheckX - BlockRmndrX;
    			}
    			else
    			{
    				BlockCheckX = BlockCheckX + 16 - BlockRmndrX;
    			}
    			float BlockRmndrY = BlockCheckY % 16;
    			if (BlockRmndrY <= 8)
    			{
    				BlockCheckY = BlockCheckY - BlockRmndrY;
    			}
    			else
    			{ 
    				BlockCheckY = BlockCheckY + 16 - BlockRmndrY;
    			}
    			int BlockPosition = (BlockCheckY & 240)+(BlockCheckX>>4);
    			
    			if ( (Screen->ComboD [BlockPosition] == Combo1 || Combo2 || Combo3 || Combo4 || Combo5 || ComboDug) || (Screen->ComboS [BlockPosition] == 15) )
    			{
    				Game->PlaySound(6);
    				Quit();
    			}
    			else if (Screen->ComboD != Combo1 || Combo2 || Combo3 || Combo4 || Combo5 || ComboDug)
    			{
    				ComboY = Link->Y - 16;
    				ComboX = Link->X;
    				float remainder = ComboX % 16;
    				if (remainder <= 8)
    				{
    					ComboX = ComboX - remainder;
    				}
    				else
    				{ 
    					ComboX = ComboX + 16 - remainder;
    				}
    				float remainderY = ComboY % 16;
    				if (remainderY <= 8)
    				{
    				ComboY = ComboY - remainderY;
    				}
    				else
    				{
    					ComboY = ComboY + 16 - remainderY;
    				}
    				int ComboPosition = (ComboY & 240)+(ComboX>>4);
    				Screen->ComboD [ComboPosition] = ComboDug;
    			}
    			else if (Screen->ComboD [BlockPosition] == ComboS1 || ComboS2 || ComboS3)
    			{
    				ComboY = Link->Y - 16;
    				ComboX = Link->X;
    				float remainder = ComboX % 16;
    				if (remainder <= 8)
    				{
    					ComboX = ComboX - remainder;
    				}
    				else
    				{ 
    					ComboX = ComboX + 16 - remainder;
    				}
    				float remainderY = ComboY % 16;
    				if (remainderY <= 8)
    				{
    				ComboY = ComboY - remainderY;
    				}
    				else
    				{
    					ComboY = ComboY + 16 - remainderY;
    				}
    				int ComboPosition = (ComboY & 240)+(ComboX>>4);
    				Screen->ComboD [ComboPosition] = ComboSDug;
    			}
    		}
    		else if (Link->Dir == 1)
    		{
    			int BlockCheckY = Link->Y + 16;
    			int BlockCheckX = Link->X;
    			float BlockRmndrX = BlockCheckX % 16;
    			if (BlockRmndrX <= 8)
    			{
    				BlockCheckX = BlockCheckX - BlockRmndrX;
    			}
    			else
    			{
    				BlockCheckX = BlockCheckX + 16 - BlockRmndrX;
    			}
    			float BlockRmndrY = BlockCheckY % 16;
    			if (BlockRmndrY <= 8)
    			{
    				BlockCheckY = BlockCheckY - BlockRmndrY;
    			}
    			else
    			{ 
    				BlockCheckY = BlockCheckY + 16 - BlockRmndrY;
    			}
    			int BlockPosition = (BlockCheckY & 240)+(BlockCheckX>>4);
    			if ( (Screen->ComboD [BlockPosition] == Combo1 || Combo2 || Combo3 || Combo4 || Combo5 || ComboDug) || (Screen->ComboS [BlockPosition] == 15) )
    			{
    				Game->PlaySound(6);
    				Quit();
    			}
    			else if (Screen->ComboD != Combo1 || Combo2 || Combo3 || Combo4 || Combo5 || ComboDug)
    			{
    				ComboY = Link->Y + 16;
    				ComboX = Link->X;
    				float remainder = ComboX % 16;
    				if (remainder <= 8)
    				{
    					ComboX = ComboX - remainder;
    				}
    				else
    				{ 
    					ComboX = ComboX + 16 - remainder;
    				}
    				float remainderY = ComboY % 16;
    				if (remainderY <= 8)
    				{
    				ComboY = ComboY - remainderY;
    				}
    				else
    				{
    					ComboY = ComboY + 16 - remainderY;
    				}
    				int ComboPosition = (ComboY & 240)+(ComboX>>4);
    				Screen->ComboD [ComboPosition] = ComboDug;
    			}
    			else if (Screen->ComboD [BlockPosition] == ComboS1 || ComboS2 || ComboS3)
    			{
    				ComboY = Link->Y + 16;
    				ComboX = Link->X;
    				float remainder = ComboX % 16;
    				if (remainder <= 8)
    				{
    					ComboX = ComboX - remainder;
    				}
    				else
    				{ 
    					ComboX = ComboX + 16 - remainder;
    				}
    				float remainderY = ComboY % 16;
    				if (remainderY <= 8)
    				{
    				ComboY = ComboY - remainderY;
    				}
    				else
    				{
    					ComboY = ComboY + 16 - remainderY;
    				}
    				int ComboPosition = (ComboY & 240)+(ComboX>>4);
    				Screen->ComboD [ComboPosition] = ComboSDug;
    			}
    		}
    		else if (Link->Dir == 2)
    		{
    			int BlockCheckY = Link->Y;
    			int BlockCheckX = Link->X - 16;
    			float BlockRmndrX = BlockCheckX % 16;
    			if (BlockRmndrX <= 8)
    			{
    				BlockCheckX = BlockCheckX - BlockRmndrX;
    			}
    			else
    			{
    				BlockCheckX = BlockCheckX + 16 - BlockRmndrX;
    			}
    			float BlockRmndrY = BlockCheckY % 16;
    			if (BlockRmndrY <= 8)
    			{
    				BlockCheckY = BlockCheckY - BlockRmndrY;
    			}
    			else
    			{ 
    				BlockCheckY = BlockCheckY + 16 - BlockRmndrY;
    			}
    			int BlockPosition = (BlockCheckY & 240)+(BlockCheckX>>4);
    			if ( (Screen->ComboD [BlockPosition] == Combo1 || Combo2 || Combo3 || Combo4 || Combo5 || ComboDug) || (Screen->ComboS [BlockPosition] == 15) )
    			{
    				Game->PlaySound(6);
    				Quit();
    			}
    			else if (Screen->ComboD != Combo1 || Combo2 || Combo3 || Combo4 || Combo5 || ComboDug)
    			{
    				ComboY = Link->Y;
    				ComboX = Link->X - 16;
    				float remainder = ComboX % 16;
    				if (remainder <= 8)
    				{
    					ComboX = ComboX - remainder;
    				}
    				else
    				{ 
    					ComboX = ComboX + 16 - remainder;
    				}
    				float remainderY = ComboY % 16;
    				if (remainderY <= 8)
    				{
    				ComboY = ComboY - remainderY;
    				}
    				else
    				{
    					ComboY = ComboY + 16 - remainderY;
    				}
    				int ComboPosition = (ComboY & 240)+(ComboX>>4);
    				Screen->ComboD [ComboPosition] = ComboDug;
    			}
    			else if (Screen->ComboD [BlockPosition] == ComboS1 || ComboS2 || ComboS3)
    			{
    				ComboY = Link->Y;
    				ComboX = Link->X - 16;
    				float remainder = ComboX % 16;
    				if (remainder <= 8)
    				{
    					ComboX = ComboX - remainder;
    				}
    				else
    				{ 
    					ComboX = ComboX + 16 - remainder;
    				}
    				float remainderY = ComboY % 16;
    				if (remainderY <= 8)
    				{
    				ComboY = ComboY - remainderY;
    				}
    				else
    				{
    					ComboY = ComboY + 16 - remainderY;
    				}
    				int ComboPosition = (ComboY & 240)+(ComboX>>4);
    				Screen->ComboD [ComboPosition] = ComboSDug;
    			}
    		}
    		else if (Link->Dir == 3)
    		{
    			int BlockCheckY = Link->Y;
    			int BlockCheckX = Link->X + 16;
    			float BlockRmndrX = BlockCheckX % 16;
    			if (BlockRmndrX <= 8)
    			{
    				BlockCheckX = BlockCheckX - BlockRmndrX;
    			}
    			else
    			{
    				BlockCheckX = BlockCheckX + 16 - BlockRmndrX;
    			}
    			float BlockRmndrY = BlockCheckY % 16;
    			if ( BlockRmndrY <= 8 )
    			{
    				BlockCheckY = BlockCheckY - BlockRmndrY;
    			}
    			else
    			{ 
    				BlockCheckY = BlockCheckY + 16 - BlockRmndrY;
    			}
    			int BlockPosition = (BlockCheckY & 240)+(BlockCheckX>>4);
    			if ( (Screen->ComboD [BlockPosition] == Combo1 || Combo2 || Combo3 || Combo4 || Combo5 || ComboDug) || (Screen->ComboS [BlockPosition] == 15) )
    			{
    				Game->PlaySound(6);
    				Quit();
    			}
    			else if (Screen->ComboD != Combo1 || Combo2 || Combo3 || Combo4 || Combo5 || ComboDug)
    			{
    				ComboY = Link->Y;
    				ComboX = Link->X + 16;
    				float remainder = ComboX % 16;
    				if (remainder <= 8)
    				{
    					ComboX = ComboX - remainder;
    				}
    				else
    				{ 
    					ComboX = ComboX + 16 - remainder;
    				}
    				float remainderY = ComboY % 16;
    				if (remainderY <= 8)
    				{
    				ComboY = ComboY - remainderY;
    				}
    				else
    				{
    					ComboY = ComboY + 16 - remainderY;
    				}
    				int ComboPosition = (ComboY & 240)+(ComboX>>4);
    				Screen->ComboD [ComboPosition] = ComboDug;
    			}
    			else if (Screen->ComboD [BlockPosition] == ComboS1 || ComboS2 || ComboS3)
    			{
    				ComboY = Link->Y;
    				ComboX = Link->X + 16;
    				float remainder = ComboX % 16;
    				if (remainder <= 8)
    				{
    					ComboX = ComboX - remainder;
    				}
    				else
    				{ 
    					ComboX = ComboX + 16 - remainder;
    				}
    				float remainderY = ComboY % 16;
    				if (remainderY <= 8)
    				{
    				ComboY = ComboY - remainderY;
    				}
    				else
    				{
    					ComboY = ComboY + 16 - remainderY;
    				}
    				int ComboPosition = (ComboY & 240)+(ComboX>>4);
    				Screen->ComboD [ComboPosition] = ComboSDug;
    			}
    		}
    		Game->PlaySound(61);
    	}
    }
    The problem is on Line 57, which is the part with the if statement checking for all those combos. This is required because, as most people know, the Shovel does not dig up certain combos, especially if they are solid (with a few exceptions). But.... I think it's the || parts that are making it not work.... That's "or", right...? I need to make sure that if the combo at that location is one of those 5 defined OR solid, it will play the SFX for blocking things with your shield (the same SFX used in the Oracles and LA for tiles you can't dig up) and end the script.... A little help, please? Oh, and thanks for all the help. I appreciate it. :)

  6. #6
    Lynel Nick's Avatar
    Join Date
    Oct 2001
    Location
    I don't remember...
    Posts
    1,918
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,819
    Level
    17
    vBActivity - Bars
    Lv. Percent
    26.21%

    Re: More Insane Script Problems!

    I see the problem... or a problem.

    Code:
    if ( (Screen->ComboD [BlockPosition] == Combo1 || Combo2 || Combo3 || Combo4 || Combo5 || ComboDug) || (Screen->ComboS [BlockPosition] == 15) )
    OR (||) cannot be used like that. You will have to place "Screen->ComboD [BlockPosition] == " at the beginning of every OR check... as this is a brand new statement you are checking to be true.

    Code:
    if ( (Screen->ComboD [BlockPosition] == Combo1 || Screen->ComboD [BlockPosition] == Combo2 || Screen->ComboD [BlockPosition] == Combo3 || Screen->ComboD [BlockPosition] == Combo4 || Screen->ComboD [BlockPosition] == Combo5 || ComboDug) || (Screen->ComboS [BlockPosition] == 15) )
    Does the script still compile with this error? I've not checked.

  7. #7
    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,433
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.12%

    Re: More Insane Script Problems!

    It'll complain that you're casting floats to bools, but it does compile. I assume that works the same way it does in C: 0 is false, anything else is true.

  8. #8
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,228
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    11,028
    Level
    31
    vBActivity - Bars
    Lv. Percent
    8.54%

    Re: More Insane Script Problems!

    Yes.

  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,276
    Level
    24
    vBActivity - Bars
    Lv. Percent
    43.97%

    Re: More Insane Script Problems!

    Gah! Now it's telling me that on Line 62, the pointer type "Screen" doesn't have a function called "ComboD"! >_< And by the way, after what Nick told me, I changed all like lines to have the Screen->ComboD things after each || . What is the problem? Oh, and it still keeps saying that it has a problem casting from float to bool on Line 57..... the one that Nick fixed....

  10. #10
    Lynel Nick's Avatar
    Join Date
    Oct 2001
    Location
    I don't remember...
    Posts
    1,918
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,819
    Level
    17
    vBActivity - Bars
    Lv. Percent
    26.21%

    Re: More Insane Script Problems!

    The casting error shouldn't prevent the script from compiling according to what has been said before. Come to think of it, I had that error a few times, myself.

    As far as the error on line 62, you did not define an index for Screen->ComboD like that of line 57. In other words...
    Code:
    Screen->ComboD; // Wrong
    Screen->ComboD[index]; // Correct
    
    // index is an integer or a variable that is an integer.
    Look at the difference between line 57 and line 62.

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