Jump to content

Photo
- - - - -

Tutorial Discussion


  • Please log in to reply
96 replies to this topic

#46 Koopa

Koopa

    The child behind the turtle

  • Members
  • Location:Switzerland

Posted 17 October 2008 - 12:35 PM

I might just be able to contribute there. I mean, I spend one day a week in a job that involves teaching the philosophy of computer science to new first-term students (among other things).

#47 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 17 October 2008 - 06:11 PM

That's the main reason I wanted to show an example of a script from start to finish, though I really don't know how helpful that'll be. Besides that and encouraging practice and questions, I'm really not too sure how to teach people to think differently.

I've got most of the basic tutorial finished. I may post what I've got so far tonight and finish the last couple of sections over the weekend.

#48 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 17 October 2008 - 07:19 PM

Wow, thank you! Many people can't wait to see it. ^^,


I do think that one way to learn to do things is by actually just sitting down and doing it, whether you know it or not, but hearing advice at the same time in case you don't know what to type in, even though you have some idea where to start. Easy to say, complicated to do. We'll work it out in the end.

#49 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 18 October 2008 - 12:30 AM

QUOTE(Saffith @ Oct 17 2008, 06:11 PM) View Post

That's the main reason I wanted to show an example of a script from start to finish, though I really don't know how helpful that'll be. Besides that and encouraging practice and questions, I'm really not too sure how to teach people to think differently.

I've got most of the basic tutorial finished. I may post what I've got so far tonight and finish the last couple of sections over the weekend.
Start with the basics, like how everything works in a loop (I think- the only programming experience I have is BASIC on my TI-84+, and that's well within rudimentary) and how variables have to be defined, etc. You know, how like every computer class starts with "Hello world!" This one would start with something simple, like making an FFC appear on screen, and moving on to progressively more difficult tasks, like editing weapon effects or manipulating Link's inventory.

In other news, CastChaos has a new tutorial up in Tips and Tricks about One-Timed Events. I'd give it a thorough look through, as it has loads of information for 2.10 questers (and us 2.5 users can learn a thing or two as well).


#50 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 18 October 2008 - 01:39 AM

QUOTE(Ebola Zaire @ Oct 18 2008, 01:30 AM) View Post
This one would start with something simple, like making an FFC appear on screen, and moving on to progressively more difficult tasks, like editing weapon effects or manipulating Link's inventory.

Yeah, that's the sort of thing I'm thinking of. Every scripting tutorial I've seen gets into user-defined variables and flow control right away. Doesn't seem like a bad idea, but then you see all the people who think they have to declare built-in variables. It's easy for those of us who understand it to forget how strange and arbitrary it seems to everyone else.

#51 Koopa

Koopa

    The child behind the turtle

  • Members
  • Location:Switzerland

Posted 18 October 2008 - 06:32 AM

Here's one of my attempts at explaining variables. If anyone likes it, I'll publish it in the scripting tutorial forum.

Variables explained with Fairies

Because programming can be hard to understand, here's a little story. Your computer, deep inside, actually has a few helpful fairies. They have pencils, erasers, paper and a giant pinboard with pins where they can pin up pieces of paper.

A variable is a piece of paper with its name written on top. A number can be written beneath the name. Only one number can go on one piece of paper, though - fairies always erase the old number before writing a new one.

When your script starts, the pinboard is almost empty. I'll talk about the "almost" later.

To write a number on a piece of paper, you need to put up the paper on the board. Fairies can only write numbers on papers that are on the pinboard and have a name on them.

Declaring Variables

To get a fairy to put up a piece of paper, you need to give a name. If you choose the name hearts, you can say int hearts; in your script. When you do that, a fairy takes a piece of paper and writes "hearts" on the top and sticks it on the pinboard. The word int is fairy-speak for "hang up a new piece of paper and write the following name on it". In fact it also tells the fairy that that piece of paper is to hold a number, because you might have other things like text on other pieces of paper.

This is called declaring the variable. It's like saying "I declare that I want to use the name "hearts" from now on."

Assigning and using variables

Now we've got some paper on the pinboard, we can tell the fairies to write numbers on it. We do that with something called an assignment. Here's how: hearts = 10;. When you say that, a fairy takes a pencil, finds the piece of paper named "hearts" and writes 10 on it.

In fact we can ask even more of our fairies. If we say a=b;, the fairy looks up what's on the paper named "b", remembers it and writes it on the paper named "a". Fairies can do math too, if we say a=a+1; a fairy reads what's on the paper named a, adds one and writes it back to the a paper.

In any assignment - that's "something with an equals sign" - the term on the left of the equals is the "name of the paper to write on" and to the right of the equals is what to write on it.

Writing numbers on papers is fun, but only for a while. It's more fun if you can do something with the papers. The name of the paper/variable, wherever it's used in your script, refers to "the number on the paper with that name". So if you say if (hearts > 1) that's telling the fairy to read what's on the paper named hearts, and if it's bigger than 1 then do something.

There's one more thing you should know. To save typing, instead of int hearts; hearts = 10; you can combine the two and say int hearts = 10;. It means exactly the same.

What not to do

Of course, if a=b+2; means "take what's written on the paper named b, add two and write that on paper a, then it implies that papers named a and b must be on the pinboard somewhere or the fairy will get confused. Confused fairies get upset and that's not nice. For that reason, there's a big fairy that watches over them all, checks all scripts before they're handed to the fairies to actually run them and rejects them if they look like they're going to confuse anyone. She's part of the compiler. More prosaically, if you try and use a variable "hearts" before you declare it, your script won't compile.

Another thing that may confuse fairies - and you - is trying to have two pieces of paper with the same name on the pinboard. Which one do you write the numbers on? You can use a variable as often as you like, but you can only decalre it once. This makes sense: int hearts; hearts = 20; hearts = 10; hearts = 5;. A fairy puts up a paper and names it "hearts". Then, one writes 20 underneath it. Next, one erases the 20 and writes 10 instead. Then the same with 5.
This, however, is not a good idea: int hearts; int hearts;. You can't hang a paper on the pinboard if there's already one of the same name there. (Ok, once you've read this fully through, you'll know when and why you sometimes can, but don't confuse yourself doing it too often.)

Something that might not confuse the fairies, but it will confuse you, is this: int a; int b; b=a; We put up two papers and copy what's on paper a onto paper b. Hold on! What number is on a paper before we write a number on it? Well, you'll get some number in any case, but you have no idea what number or how it got there. Don't do this. (I must mention that this does compile. The reason can't be explained with our paper analogy, just know the comiler fairies can't tell if you've actually written a number on a paper because they only check the names.)

Scope

Before you really understand variables, there's two more important points. The first is known as scope. In fact, you see, there's not just one pinboard. There's a whole line of them. When your script starts, there's only one board up (more on this later) but more can come and go. Scripts have things called blocks. A block starts with a { and ends with a }. There are several blocks that any script has - anything with those curly brackets, including the start and end of your script, is a block.

The block rules are: 1. Whenever a new block opens, the fairies put up a new pinboard. In your script, there's typically a whole line of pinboards. 2. Any new pieces of paper put up always go on the last board in the line. 3. When a block closes, the last pinboard is taken down and all pieces of paper on it go into the trash. 4. The fairies can read and write numbers from papers whichever of the boards they are on. The whole line of boards is like one big board here (almost). Note: This rule is not quite correct. I will explain.

Why do we bother with so many boards? Well, there's only a limited number of sensible words in the language. And there's only 26 letters. If we didn't have boards, then if you used the name "a" or "hearts" somewhere, you couldn't use that name anywhere else. If you had two scripts or two functions in a script, you could only use "a" in one of them. That would be a pain when combining scripts. Also, if you used a script three times, and it used a variable "hearts", then that would mean three piees of paper named "hearts" and upset fairies. But every script and function (I might explain that term in another tutorial) is its own block - they start and end wiht { } after all - so if you use a script two times, first a board is put up, a paper put on it, and at the end the board and paper taken down again. When the second time comes, a new board goes up and because the old paper was cleared away, it's perfectly ok to put a new one up.

Here's an example. Anything after "//" is a comment.
CODE
{ // Put up a board.
hearts = 10; // BAD. No paper "hearts".
int hearts; // Put up a paper named hearts.
hearts = 10; // Write 10 on paper named hearts.
} // Take down the board, and throw away the paper.
hearts = 10; // BAD. No paper "hearts" anymore.


There's another thing though. Here's the real rule 4: There can be at most one piece of paper for each name per board. If there are several boards with papers with the same name on, only the last one counts.
Again, an example to take this rather complicated rule in.
CODE
{ // Up goes baord 1.
int a=10; // Put a paper named a on board 1 and write 10 on it.
int b; // Put a paper named b on board 1.
{ // Put up a new board.
int a = 20; // Hang up a paper named a on board two and write 20 on it.
// This "hides" the other paper, but does not erase the 10.
b = a; // Literally, "write onto paper b whatever is on paper a".
// By the last-board-counts rule, paper b on board one gets the number from
// paper a on board two, that is 20.
} // Take down board 2 and its paper a.
// We now have one board up and two papers: a with number 10, b with 20.
} // Take down board 1 again too.


Global variables

Ok. Here's a sort of exception to all the rules above. You remember I said that when your script starts, the board is "almost" empty?

When your script starts, there's already a "board 0" up. And it already has some papers on it. They have names and numbers on them already. These were put up by the zelda classic startup fairy when the game started, and stay there until you close zc. All variables on board 0 are known as global variables. There's two important points.

Firstly, you never need to declare global variables you'd like to use. Because the papers were put there by the zc startup fairy.

Secondly, while you can do what you want with your own variables, global variables are there for a reason. There are other fairies observing them that do things when you change them. For instance, two of these globals are Link->X and Link->Y. Your scripts use variables, but so does ZC itself. Think of globals as variables that belong to ZC tiself, but that your script is allowed to use too.

Whenever you press the "RIGHT" key, the keyboard fairy tells the movement fairy that you'd like to move right. The movement fairy looks at the screen to see if you can actually move and wouldn't land in a bush or something. If you can move, the actual "move" consists of the movement fairy flying to board 0 and adding one to the Link->X variable. Then, the fairy observing that variable sees it, flies to the screen and moves Link's sprite one to the right.

Which means - if you change Link->X then you're in effect moving Link! And if you move him onto an unwalkable combo - remember the movement fairy checks if Link actually can move before changing the number - you're bypassing that check and you're likely to get him stuck.

Another warning. As all global variables have meanings, Link->X = -99999999; is a really bad idea. You'll confuse the fairy who then tries to move Link's sprite way off-screen. (And the player.) Using globals in a way they're not meant - remember, they're ZC's variables, not yours - is likely to crash ZC or do other random undesirable things. Before you fiddle with one, read up on what it's values mean.

So, I hope I've managed to clear up one or two of the FAQ surrounding variables with this explanation. Be nice to the fairies, and ZC will be nice to you. ~Koopa

#52 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 03 November 2008 - 07:54 PM

Whoa, I can't believe I've missed this. icon_doh.gif Very good, I enjoyed the metaphor.

In other news, our first scripting tutorial is up and running! Be sure to check it out, Plissken's put plenty of work in to it and we're awful proud of the guy.

#53 Moonbread

Moonbread

    Playing With Psychos

  • Members
  • Pronouns:They / Them

Posted 06 December 2008 - 04:11 PM

OMGZ Alive.

Can someone make a Simplified LttP Mountains (the ones in DoR 2.0) tutorial? They're killing me icon_frown.gif

#54 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 07 December 2008 - 01:51 AM

A scripting tutorial needs to be explained step by step,giving small examples and reaching to high examples. Other people(aside from some of us scripters here that already know all this stuff) see a script and goes crazy. Or get lost in a tutorial by just reading the second paragraph. We have to be more clear on things and explained certain things repeatedly, give pop-quizzes and such at the end of a paragraph or a function definiton. People need to learn. We have to drill it to their heads. This is also a zelda classic feature that people need to learn. But that's when we come in. For us that know these things and see it so simple, stop and think that others don't know this. Some even fail math in high school or middle school. And since math is a big part in all programming languages, it has to be explained clearly and simple. Not for us at a beggining of a second paragraph, throw in a code with a whole bunch of
CODE
Abs(Link->X < this-X - 16 && Link-Y < this-Y + 16 )
statements that when other people see it, they stop reading because they get intimidated in such variables and pointer and the word "abs" which we all know means the absolute value of a statement or function. So we have to be more considerate and put ourselves in other people's shoes and be more patient and more teacher-like and drill all these concepts in their heads before 2.5 gets released.

Edited by drzchulo973, 07 December 2008 - 02:22 AM.


#55 Bourkification

Bourkification

    Magus

  • Members

Posted 07 December 2008 - 03:59 AM

QUOTE(Moonwhisper @ Dec 7 2008, 07:11 AM) View Post

OMGZ Alive.

Can someone make a Simplified LttP Mountains (the ones in DoR 2.0) tutorial? They're killing me icon_frown.gif

Go to the end of the tile list in DoR, and there is a diagram that will help you with the mountains.

#56 jerome

jerome

    "Ducks eat for free at Subway"

  • Members
  • Real Name:Jerome
  • Location:Cocoa, FL

Posted 20 January 2009 - 03:49 PM

I have a request for a tutorial if it hasn't been done elsewhere.

How to change sound effects (SFX) in quests.

I mostly need to know for an idea I am currently working with, and it involves mp3's as well. Maybe that can be put in the tutorial as well.

I'm really out of ideas otherwise, so... icon_smile.gif

#57 KrazeeN8V

KrazeeN8V

    Newbie

  • Members
  • Real Name:Steven
  • Location:Alamo... please don't cuss

Posted 28 April 2009 - 04:03 PM

umm can someone help me? i dont know how to: File-Import-Tiles and when i try to figure out something comes up saying "Value" and i do not know what that means, and ppl keep telling me to use grab but i dunno how that worx either so i am asking for help from someone who is experienced plz.

#58 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 29 April 2009 - 03:15 PM

Using grab is easy. Go to quest-tiles. Go to a blank tile, and press the grab button on the bottom. Then select a picture. The picture will come up. Then just click on the tile you want out of it.

#59 Banjo7J

Banjo7J

    Defender

  • Members
  • Real Name:John
  • Location:Scotland

Posted 02 August 2009 - 06:05 AM

I have a question about CastChoas's One-Timed Events Tutorial. Can you have multiple events on one screen but with different Trigger Screens? Example:Event screen has a Gleeok statue blocking top door and Aquamentus statue blocking right door. In trigger room 1, you must beat a gleeok to destroy the Gleeok statue and in trigger room 2, you must beat an Aquamentus to destroy the Aquamentus statue. Is said example possible without the Gleeok's death destroying the Aquamentus statue?

EDIT: Never mind.

Edited by Banjo7J, 05 August 2009 - 10:34 AM.


#60 Jack_of_blades

Jack_of_blades

    Experienced Forumer

  • Members
  • Real Name:STERRNNN!!!!!!
  • Location:Scumdogia

Posted 07 September 2009 - 12:40 AM

I have a question, is there a tutorial for creating weapons and alternate beams on the ZC Betas?
I was just wondering, because I created some nice graphics for my quest I'm creating.
*Edit
Please PM me with a link.

Edited by Jack_of_blades, 07 September 2009 - 12:42 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users