Jump to content

Photo

ZScript help?


  • Please log in to reply
10 replies to this topic

#1 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 23 November 2007 - 11:11 PM

Yeah, I'm finally getting off my butt (I'll be sitting in front of a computer anyway, so technically, I'm not icon_razz.gif ) and trying to learn ZScript. I understand some basic concepts, but when it comes to making a working script, forget it. But everyone's like that when they start out, right?



CODE
import "std.zh"
ffc script titlescreen
//This script, when attached to an ffc, makes it so that if you press the
//"Start" button on a screen, the player moves south quickly, making him hit the
//bottom of the screen, activating the sidewarp.
{
   void run()
   {
      if(Link-> Input==Start)
      {
         Link -> Y + 16;
      }
   }
}




I thought that would work, but when I tried to compile it in ZQuest, I got an error about the Input==Start bit. Can someone help?



#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 24 November 2007 - 04:45 AM

QUOTE(Beta Link @ Nov 23 2007, 10:11 PM) View Post

Yeah, I'm finally getting off my butt (I'll be sitting in front of a computer anyway, so technically, I'm not icon_razz.gif ) and trying to learn ZScript. I understand some basic concepts, but when it comes to making a working script, forget it. But everyone's like that when they start out, right?



CODE
import "std.zh"
ffc script titlescreen
//This script, when attached to an ffc, makes it so that if you press the
//"Start" button on a screen, the player moves south quickly, making him hit the
//bottom of the screen, activating the sidewarp.
{
   void run()
   {
      if(Link-> Input==Start)
      {
         Link -> Y + 16;
      }
   }
}




I thought that would work, but when I tried to compile it in ZQuest, I got an error about the Input==Start bit. Can someone help?



Yeah, it's tough to get off the ground initially. Do yourself a favor and have a copy of std.zh and Zcript document open while your working on stuff.

What you want is:

while(true){ // this is a while loop, it runs while the () are true. (true) happens to ALWAYS be true.


if(Link->InputStart){



Link->Y +=16, // or I prefer the Link->Y = Link->Y + 16;


and finally to tell a loop to stop for a frame:

Waitframe(); // otherwise ZC will freeze.

#3 Joe123

Joe123

    Retired

  • Members

Posted 24 November 2007 - 06:22 AM

Because what you have at the moment will only happen once, and you want it to continue happening until Link is pushed off the screen.

And you're using Link->Input wrong. Gleeok corrected that, but he didn't explain what he did so I'll explain it.
In ZScript, there are variables. I'm aware of 3 types of variables (not so say there aren't more =P), and these are
Int - short for Integer, this stores a numerical value
Bool - short of Boolean, this stores a 'true/false' value
Float - short for Float, this stores a decimal numerical value
(by the way, integers are lying, you can also save them with decimal places)
The Link->Input command is a boolean, and you've tried to use it an an integer. (you're probably thinking, what's he on about, 'start' isn't a number?!, well if you try to use a word in place of a number, ZScript assumes you're trying to refer to a variable integer, which has been named with that word, so where you've put 'Link->Input == start', aside from the fact that just 'Link->Input' on it's own isn't a command, ZScript assumes that start is an integer. Which is bad because you haven't declared it)
Anyway, there are 9 commands that start with 'Link->Input', and the one you want is 'Link->InputStart'. If you want to access another button press, you just put that on the end, ie. 'Link->InputLeft'. And because it's a boolean, and you want to check if it's true, you want to put 'if(Link->InputStart == true){' (or as Gleeok put, just 'if(Link->InputStart){' because for a boolean that implies that you want it to be true anyway, but I wouldn't worry about that too much right now).

Also, there are better ways of making Link warp via ZScript than this.
Firstly, if you hold down 'Up' after pressing start, Link might be able to escape hitting the side warp (although moving at 16 pixels a frame is rather fast so I don't think he'd be able to escape that, I think he usually walks at one pixel a frame).
If you look in ZScript.txt, which is the document containing all of the commands for ZScript, and how to use them, you'll see there is Link->Warp(); and Link->PitWarp();.

Just on a side note, the document is split up into sections. for the commands in the section called 'Link', you have to put 'Link->' before the command, this is called a pointer. So to make the game play a SFX, which is in the 'Game' section, you have to put 'Game->PlaySound();'. I had no idea of this, and it took me quite a while to work it out, so hopefully it'll be helpful to you.

Anyway, so if you were to put in 'Link->PitWarp(dmap, screen);' rather than Link->X, it would send Link via a scripted warp, without having to mess around with moving Link.
You have to understand integers however to make this work. If you want to use this script here, and only here, you could hard-code into the script your warp destination, or you could put some variable integers in the FFC's D0-D7 boxes, which I'll explain if you want?
Anyway, 'dmap' is just the number of the dmap you're going to, and screen is the number of the screen. Screens are counted across the top from 0-15, then on the next row from 16-31 etc.

This however isn't my preffered method, I'd make a combo into an autowarp type after you press start, which then sends Link via the sidewarp as it is. I was going to post up my script for making Link warp after you press start, but I thought I wouldn't because if you just use mine it wouldn't help your understanding, and you said you wanted to learn. I'll put it up if you want, though?
And if there's anything that I said that you don't understand, feel free to ask =P

It's great to see people learning though, good luck icon_biggrin.gif

Edited by Joe123, 24 November 2007 - 06:23 AM.


#4 Zelda Rocks

Zelda Rocks

    Recipient of Ways

  • Members

Posted 24 November 2007 - 07:02 PM

Thanks guys, that was a huge help. icon_biggrin.gif Now, just taking what Gleeok told me to do, I've redone the script...

CODE
import "std.zh"
ffc script titlescreen
//This script, when attached to an ffc, makes it so that if you press the
//"Start" button on a screen, "Link" moves south quickly, and hitting the
//side of the screen, activating the sidewarp.
{
   void run()
   {
       while(true)
       {
           if(Link->InputStart)
           {
               Link->Y+=16
               {
                   Waitframe();
               }
           }
       }
   }
}


Also, a question: Where in Link->Warp(dmap, screen) would you put the coordinates? Would it be like
"Link->Warp(1, 72)" or "Link->Warp(dmap1, screen72)? I think I understand more how ZScript works now. icon_smile.gif Thanks a lot, guys!

Edit: Crap, I forgot to log my brother off again. Sorry, it's Beta Link, not Zelda Rocks.

Edited by Zelda Rocks, 24 November 2007 - 07:04 PM.


#5 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 24 November 2007 - 08:28 PM

QUOTE(Zelda Rocks @ Nov 24 2007, 06:02 PM) View Post

Thanks guys, that was a huge help. icon_biggrin.gif Now, just taking what Gleeok told me to do, I've redone the script...

CODE
import "std.zh"
ffc script titlescreen
//This script, when attached to an ffc, makes it so that if you press the
//"Start" button on a screen, "Link" moves south quickly, and hitting the
//side of the screen, activating the sidewarp.
{
   void run()
   {
       while(true)
       {
           if(Link->InputStart)
           {
               Link->Y+=16
               {
                   Waitframe();
               }
           }
       }
   }
}


Also, a question: Where in Link->Warp(dmap, screen) would you put the coordinates? Would it be like
"Link->Warp(1, 72)" or "Link->Warp(dmap1, screen72)? I think I understand more how ZScript works now. icon_smile.gif Thanks a lot, guys!

Edit: Crap, I forgot to log my brother off again. Sorry, it's Beta Link, not Zelda Rocks.


Good job. Now you need waitframe in a place where there is no if(condition)....!

CODE
import "std.zh"
ffc script titlescreen
//This script, when attached to an ffc, makes it so that if you press the
//"Start" button on a screen, "Link" moves south quickly, and hitting the
//side of the screen, activating the sidewarp.
{
   void run()
   {
       while(true)
       {
           if(Link->InputStart)
           {
               Link->Y+=16; //semicolon!!!!!
              // {
                   //Waitframe();
             //  }
           }
     Waitframe();
       }
   }
}

Edited by Gleeok, 24 November 2007 - 08:28 PM.


#6 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 24 November 2007 - 09:11 PM

Ok, final version...



CODE
import "std.zh"
ffc script titlescreen
//This script, when attached to an ffc, makes it so that if you press the
//"Start" button on a screen, "Link" moves south quickly, and hitting the
//side of the screen, activating the sidewarp.
{
   void run()
   {
       while(true)
       {
           if(Link->InputStart)
           {
               Link->Y+=16;
           }
           Waitframe();
       }
   }
}




Is that right now?
Edit: It compiles well in ZQuest, but will it do what is expected?

Edited by Beta Link, 24 November 2007 - 09:14 PM.


#7 Joe123

Joe123

    Retired

  • Members

Posted 25 November 2007 - 05:12 AM

QUOTE(Zelda Rocks @ Nov 25 2007, 12:02 AM) View Post
Also, a question: Where in Link->Warp(dmap, screen) would you put the coordinates? Would it be like
"Link->Warp(1, 72)" or "Link->Warp(dmap1, screen72)? I think I understand more how ZScript works now. icon_smile.gif Thanks a lot, guys!


Link->Warp(1,72); would be the correct syntax. You could put Link->Warp(dmap1, screen72); but you'd have to declare integers.

CODE
import "std.zh"
ffc script titlescreen{
//This script, when attached to an ffc, makes it so that if you press the
//"Start" button on a screen, "Link" moves south quickly, and hitting the
//side of the screen, activating the sidewarp.
   void run(){
       while(true){
           if(Link->InputStart){
               Link->Y += 16;
           }
       Waitframe();
       }
   }
}


And why did you have the left braces on seperate lines to the loops? Not that you can't do that, but it looks harder to read to me.
Maybe not to you I suppose icon_shrug.gif most people seem to put them at the end of the loops though.

Edited by Joe123, 25 November 2007 - 05:17 AM.


#8 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 25 November 2007 - 12:42 PM

Yeah, I put the braces like that because it's easier for me to read. That way, everything's more spaced out, rather than squeezed together. I can see how doing it the other way would be better though. icon_confused.gif By the way, do you think you could explain to me the thing you were talking about before with the variable integers and the FFC's D0-D7 boxes?

#9 Joe123

Joe123

    Retired

  • Members

Posted 25 November 2007 - 12:57 PM

Ah, fair enough. When I first started, I noted every single loop to tell me where it started and ended.

And of course I can icon_wink.gif

Do you understand declaring integers?
I explained variables earlier. Integers are a type of variable, which you give a name (such as 'int1', or 'x' or 'apocalypticmegadeathrayswitch'). You can then set them to values, to do things in the script.
You must, however, declare them at some point in the script, otherwise ZScript hates you.

You declare them by putting at some point in the script (usually after void run(){ but it's not necessary to declare them there) 'int x = #;', where x is the name of the integer and # is a numerical value, then wherever you put 'x' in the script, ZScript reads the value that you set it to.
You access them in the script by 'x = #;', to make the distinction between declaration and usage. ('=' means 'is set to', and '==' means 'equals')

The D0-D7 variables are a little different though, they are declared within void run(){, ie:
void run(int x, int y, int deathray){
Then, ZScript reads the values from the D0-D7, in order across those integers. Just adds a little more flexibility to scripts really. You can still set them to different values if you want to at a later stage in the script.

#10 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 25 November 2007 - 01:08 PM

Ok, just so I'm clear on this: If I wanted to do a scripted warp, it would go something like this:

...
void run (int dmap, int screen)'
...
Link->Warp(dmap, screen)
...

That's correct, yes? Or no?

Edit: I just put the warp and integers and stuff into the script, and compiled it in ZQuest. There weren't any problems in compiling it! icon_smile.gif

Edited by Beta Link, 25 November 2007 - 01:15 PM.


#11 Joe123

Joe123

    Retired

  • Members

Posted 25 November 2007 - 01:11 PM

yup, fine.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users