LockBlockShake
#16
Posted 30 November 2008 - 07:18 AM
#17
Posted 30 November 2008 - 07:26 AM
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:
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:
That line of code would produce the same effect as the first one.
Edited by Joe123, 30 November 2008 - 07:33 AM.
#18
Posted 30 November 2008 - 07:42 AM
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
Posted 30 November 2008 - 07:57 AM
Screen->ComboD is an integer, just like if we make our own integer.
So that means we use it in the same way:
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:
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
Posted 30 November 2008 - 08:24 AM
//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
Posted 30 November 2008 - 07:35 PM
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.
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