PDA

View Full Version : Better looking Ladder/Vines script



Joe123
09-13-2007, 11:41 AM
You know how ladders and vines are usually placed down just as 'slow walk' combos?

Could someone make or refer me to a script that replaces all of Link's walking tiles to just the up facing ones, and disables him from using any items whilst he is climbing the ladders please?

C-Dawg
09-13-2007, 09:08 PM
Should be pretty simple to script, but remember you can simulate this by sacrificing the flippers. (Give player flippers, disable diving, vines are water, swim tiles are climbing.)

Joe123
09-14-2007, 02:33 AM
Yeah, I know I could do it via not using the flippers - but then I can't use the flippers ;)

C-Dawg
09-14-2007, 09:07 AM
Alright, hell, here's a script to try.



ffc script climbing{
void run(int top_left_x, int top_left_y, int bottom_right_x, int bottom_right_y,){

dummy_item_id = 0; // Dummy item with a Link offset, used to
// change the player's graphics while climbing.

while(true){

// Is the player within the rectangle specified in the data?
// ----------------------
if( (Link->X >= top_left_x) && (Link->X <= bottom_right_x) &&
(Link->X >= top_left_y) && (Link->Y <= bottom_right_y)){

if(!Link->Item[dummy_item_id]){ Link->Item[dummy_item_id] = true;}
Link->InputA = false;
Link->InputB = false;

}else{

if(Link->Item[dummy_item_id]){ Link->Item[dummy_item_id] = false;}

}

Waitframe();
} // end of while loop

} // end of void run
}


Havn't compiled it, but I imagine it should work fine. Provide it, as input, the X and Y coordinates of the top left and bottom right of the ladder. Some notes on use:

1. As written, it won't work if Link is walking horizontally and standing on the top half of the ladder, with no ladder above him.

2. As written, if Link leaves the screen running this script while still on a ladder, the dummy item will stay in his inventory. Fix by ensuring that Link can never leave a screen while staying on this script OR by ensuring the script is also running where Link arrives on the next screen.

3. You should still use Slow Walk combos.

EDIT: Alternative version, this doesn't use dummy items, just makes player face north:



ffc script climbing{
void run(int top_left_x, int top_left_y, int bottom_right_x, int bottom_right_y,){

while(true){

// Is the player within the rectangle specified in the data?
// ----------------------
if( (Link->X >= top_left_x) && (Link->X <= bottom_right_x) &&
(Link->X >= top_left_y) && (Link->Y <= bottom_right_y)){

Link->Dir = 0;
Link->InputA = false;
Link->InputB = false;

}
Waitframe();
} // end of while loop

} // end of void run
}

Joe123
09-14-2007, 01:44 PM
Where am I supposed to input the coordinates? I've tried putting them into the brackets after the void run command instead of the top_left_X etc. integers both instead of and aswell as the words 'top left X', but I know very little about Zscript and I'm asuming that's incorrect, as it won't compile with it as either of those, or without changing it. Zquest says there's an error in both of the scripts on the void run line, when they're unchanged.

C-Dawg
09-14-2007, 07:00 PM
Oh, I just added an extra "," inside the parentheses in each void run statement. The last one, at the end. Take that out and you'll be fine.

When you code:

void run (int x, int y){

What Zquest does is loads the Data arguments for that FFC, in order, as variables for the script. So you can attach Script #1 (climbing script) to FFC #1, then click on the "arguments" or "data" tab, and put in 1 for D0, and 2 for D1. When the script runs, it will load 1 into integer x, and 2 into integer y. You do this in order to re-use a script with different variables whenever you want. Or you can run it on several different FFCs to make multiple ladders.

Get it?

Joe123
09-14-2007, 07:22 PM
Ah. I thought it would make sense to input the coordinates via arguments, but then when it didn't compile properly I thought that would be because I had to input them into the script somewhere.

Thanks a lot.

EDIT: the one without the dummy item compiles and everything fine, but then when you try to use it, Link has the moving upwards sprite overlayed transparently over the moving downwards sprite, and can't move down. And if you have a ladder more than one tile wide, Link can't walk between the
two rows horizontally, just won't work

The one with the dummy item still won't compile after removing that comma, apparently there is an error to do with the 'Dummy_item_id' variable being undeclared.
EDIT 2:OK, I've worked out the dummy item script now, and it works fine. You'd missed the 'int dummy_item_id' variable in the void_run command, which meant it wouldn't compile, and being a rather new to scripting (and 2.5 betas for that matter) I didn't think to actaully make the dummy item, and give it a number in the script. All works fine and dandy now though. Although the other script doesn't.

EDIT 3: OK, actaully it doesn't work fine and dandy. I've set the coordinates for the top left of the ladder, but the script seems to carry on to the top of the screen for no apparent reason.

EDIT 3:I've fixed the script:

ffc script climbing_dummy_item{
void run(int top_left_x, int top_left_y, int bottom_right_x, int bottom_right_y, int max_y, int dummy_item_id){

dummy_item_id = 0; // Replace this 0 with the number of the dummy
// item that has been made with a link tile mod.

while(true){

// Is the player within the rectangle specified in the data?
// ----------------------
if( (Link->X >= top_left_x) && (Link->X <= bottom_right_x) &&
(Link->X >= top_left_y) && (Link->Y <= bottom_right_y) && (Link->Y >= max_y)){

if(!Link->Item[dummy_item_id]){ Link->Item[dummy_item_id] = true;}
Link->InputA = false;
Link->InputB = false;

}else{

if(Link->Item[dummy_item_id]){ Link->Item[dummy_item_id] = false;}

}

Waitframe();
} // end of while loop

} // end of void run
}

:)

And to have two different ladders on one screen, I found it necessary to have more two dummy items, identical apart from reference number, and having two scripts - one with each item number.