Jump to content

Photo

LockBlockShake


  • Please log in to reply
20 replies to this topic

#16 Christian

Christian

    Summoner

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

Posted 30 November 2008 - 07:18 AM

Its off-topic but just go over it real quick, I don't want to go back and read the loops all over again, don't want to get confused even though I already know what they do.

#17 Joe123

Joe123

    Retired

  • Members

Posted 30 November 2008 - 07:26 AM

Right well.
The way ZC stores what combos are on a given screen is using an array.

Or in easier to understand terms, each combo is assigned a number on the screen.
So the combo in the top left hand corner is combo 0, the next one over is combo 1 etc.
The combo directly below the top left combo is combo 16, and the one in the bottom right hand corner is combo 175.

This lets use manipulate combos with ZScript.

So if I wanted to change the combo ID number of second combo over in the second row, I could do this:
CODE
Screen->ComboD[17] = newcomboID;

Obviously that's pretty awkward to use though, because we humans like x and y coordinates for positions on screens.

So when you use ComboAt, what it does is take the x and y coordinates of a combo, and work out the combo's position on the screen as a single number from those coordinates.

So that's why we use it like this:
CODE
Screen->ComboD[ComboAt(16,16,)] = newcomboID;


That line of code would produce the same effect as the first one.

Edited by Joe123, 30 November 2008 - 07:33 AM.


#18 Christian

Christian

    Summoner

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

Posted 30 November 2008 - 07:42 AM

So we use "ComboAt" for that, to set up the coordinates. If I want to use
CODE
Screen->ComboD[ComboAt(this-X,this->Y) = newcomboID
I'm actually setting up the x and y coordinates myself on the ffc editor window in zquest right. But how would ZC classic know what combo I.d we're talking about when the combo I.d inside the "[]" was overwritten with the x and y coordinates? And what goes on the newcomboID? Is it another array? That equals the current comboID we're using?

And everytime we use these methods, must I give it a while loop ending with a Waitframe();?

Edited by drzchulo973, 30 November 2008 - 07:48 AM.


#19 Joe123

Joe123

    Retired

  • Members

Posted 30 November 2008 - 07:57 AM

Ah, I obviously should've explained Screen->ComboD a bit better.

Screen->ComboD is an integer, just like if we make our own integer.
So that means we use it in the same way:

CODE
int james = 48;
Screen->ComboD[ComboAt(james,16)] = 7;
if(james == 10){}
if(Screen->ComboD[3] == 12){}


The number inside the square brackets only tells Screen->ComboD which combo on the screen is being altered.
You then set it to a value to actually alter that combo.

So...
Say we want to change the combo where the ffc is to be a tree.
We'd do it a bit like this:
CODE
Screen->ComboD[ComboAt(this->X,this->Y)] = treecombo;

Where 'treecombo' is the combo ID of a combo with a tree graphic.

So we've set the value of 'Screen->ComboD' at the position '(this->X,this->Y)' to 'treecombo'.
Does that make a little more sense?

this->X and this->Y are the x and y coordinates of the ffc combo that the script is applied to by the way.

You can also use it in an if to check whether the combo ID at a certain point is what you want it to be.

And you don't have to put it in a loop with Waitframe(), it depends how you want to use it.

If you want to keep changing a combo's ID number every frame, then yes, you'd put it in a loop with Waitframe();
Generally speaking though I'dve thought most people don't want to do that.

That's more useful if you want to check the combo ID of something every frame.

Edited by Joe123, 30 November 2008 - 07:57 AM.


#20 Christian

Christian

    Summoner

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

Posted 30 November 2008 - 08:24 AM

Hmmm is this reasonable
CODE

//plays a message when link faces up the tree and hits A
ffc script tree talk{
        Void run(int m){
int treecombo = Screen->ComboD[32];//combo I.d of the tree
int apples = ComboAt(this-X,this->Y);
     if(Screen->Combo[apples] == treecombo;
     if(Link->Dir == 0 && Link->DIR_UP);
           while(true){
                Link->InputA =true;
                Screen->Message(m);
                 Waitframe();
                 }
          }end of void run
}End of script

will that work? Or did I messed up big time? But my main focus is how I used the ComboD and ComboAt. Did I used them properly?

Edited by drzchulo973, 30 November 2008 - 09:45 AM.


#21 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 30 November 2008 - 07:35 PM

QUOTE(drzchulo973 @ Nov 30 2008, 08:24 AM) View Post

CODE

if(Screen->Combo[apples] == treecombo;
if(Link->Dir == 0 && Link->DIR_UP);



Not quite. As far as what you are focusing on, in the if condition, you forgot to add the "D" to the end of "Screen->ComboD". Otherwise, I guess you could say that you used them correctly (as far as the format of them goes), but the script definitely won't accomplish what you are trying to do. Basically all you would need is the "signpost" script to accomplish your goal (whcih I don't feel like looking for at the moment, but I can post my version of it if you wish.)

There are a few reasons why your script won't work. First, as can be seen in the quote, you used the if condition wrong on both lines. The way you use an if condition is as the following.

CODE

if(Screen->ComboD[apples] == treecombo)
{
    //do something here if the combo at location "apples" is the same as the combo where the ffc is located
}


However, you forgot the brackets around the code to run if the condition is true, and you used a semicolon. A semicolon is not needed for an if condition. (Plus, Link->DIR_UP doesn't exist, and you already checked if Link->Dir==0 anyways.) By the way, Saffith's beginner tutorial can help to explain the concepts related to the mistakes you have been making commonly so far.

Second, you need to think about what exactly needs to happen before writing the script. What you want is when Link is below the treecombo, is looking up, and presses A, a message will play. In order to write this then, you will need a loop to keep checking whether Link's position on the screen is close enough to the location of the tree and whether he is pressing the "A" button or not. If the ffc is placed at the same spot as the tree, you won't need to use Screen->ComboD or ComboAt() at all in order to do this.

Edited by Elmensajero, 30 November 2008 - 07:40 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users