-
Sidescroll Ladder Script
Hey guys, this is my first post here. I recognize a lot of people.
Anyway, I need a script made for sidescroll ladders.
I need either a combo type or a flag that, when Link stands on it, he won't fall with "Sideview Gravity" checked. Kind of like the ladders in Link's Awakening.
I made the same request at PZC but I heard that there are some expert scripters here.
Can anyone make the script?
-
Re: Sidescroll Ladder Script
Hmm... Sounds doable. Gimme a few minutes.
-
Re: Sidescroll Ladder Script
Ok, done. It's very basic, but very easy to use. Just assign the script to any old FFC, and you're done.
http://zctut.com/ladder.php - Archived on my site
It uses flag #98 (the first of the flags set aside just for scripts), but you can change that by passing the flag number in to D0.
As a bonus, I was going to throw in an option of forcing Link to face up while on a ladder (a la Gameboy Zeldas), but Link is not very flexible, and I ended up having to re-invent his movement and collision detection, and it was buggy anyway. So, I just left it at that.
-
Re: Sidescroll Ladder Script
Wait, so all we have to do is attack the script to any FFC in the screen. Then how does it know what combos are the ladder combos?
-
Re: Sidescroll Ladder Script
Quote:
Originally Posted by
pkmnfrk
It uses flag #98 (the first of the flags set aside just for scripts), but you can change that by passing the flag number in to D0.
Read closer
-
Re: Sidescroll Ladder Script
You can make him face upwards via Link Tile Modifiers.
http://www.armageddongames.net/forum...ad.php?t=99828
-
Re: Sidescroll Ladder Script
Finally. Real ladders. And combined with Joe's script, we have treu sideview ladders. Is there anything scripting can't do?
-
Re: Sidescroll Ladder Script
*posts on PZC*
Beautiful. The whole ZC world should know about this script.
-
Re: Sidescroll Ladder Script
Quote:
Originally Posted by
russadwan
Finally. Real ladders. And combined with Joe's script, we have treu sideview ladders. Is there anything scripting can't do?
Yes, but there's always a workaround.
-
Re: Sidescroll Ladder Script
Hey, pkmnfrk:
I have been trying out the script you made for one of my quests. It's wonderful... :) but can you make an improvement?
I found a flaw. Using the script while Link has Z3 (diagonal) movement, when he walks at the bottom of the ladder in a gravity screen and it is a solid floor with no flag, he walks in one solid tile down.
You can reply here, but I liked to be notified too because I don't come here often, so send in a PM to me also.
-
Re: Sidescroll Ladder Script
Oohh... huh. I was hoping to avoid having to check for diagonals... Hmm, let me think on this...
Quote:
Originally Posted by
zcAmazing
You can reply here, but I liked to be notified too because I don't come here often, so send in a PM to me also.
There is a thread subscription option. I'll send you a PM once, if/when I update the script.
-
Re: Sidescroll Ladder Script
It doesn't work!
Quote:
Originally Posted by Compile Progress
PASS 1: PARSING
LINE 41: SYNTAX ERROR, UNEXPECTED $END, EXPECTING RBRACE, ON TOKEN
FATAL ERROR P00: CAN'T OPEN OR PARSE INPUT FILE!
-- PRESS A KEY --
-
Re: Sidescroll Ladder Script
Ah, cripes. My bad, I forgot a } in the code block. Try it now.
-
Re: Sidescroll Ladder Script
-
Re: Sidescroll Ladder Script
Did you recopy the script? Or, add the } at the end? I know for a fact this script works.
-
Re: Sidescroll Ladder Script
Well apparently, you have to put all the scripts in one file. (Which I didn't know.)
-
Re: Sidescroll Ladder Script
pkmnfrk, when going on the ladder with flag 98's for that sideview ladder script while Link has the Hover Boots item, as he goes up, the Hover Boots takes effect repeatedly. As he goes down, he acts flickering funny. Can you add to your script that prohibits the use of Hover Boots when Link is on Flag 98?
-
Re: Sidescroll Ladder Script
Yes, I can. But, I just thought about it, and there isn't really any foolproof method of ensuring that Link has the hover boots when he leaves the screen. Consider this:
Code:
bool hashover;
hashover = Link->Item[I_HOVERBOOTS];
while(true) {
//...
if(this combo is 98)
Link->Item[I_HOVERBOOTS] = false;
else
Link->Item[I_HOVERBOOTS] = hashover;
Waitframe();
}
This code works great as long as Link is on the screen. And, heck, if he leaves the screen while not on a ladder. However, if he leaves via a warp on a ladder (a very common thing one would do), then the last thing it would do is take away his boots, and then the script dies!
The only thing I can suggest is disabling the hoverboots on screens with ladders, OR waiting until 2.5+ to get real ladders.
-
Re: Sidescroll Ladder Script
Or putting flag 98 and that script around the warp destination?
-
Re: Sidescroll Ladder Script
No, that wouldn't work. Look again at my code. It records whether Link has the hover boots or not, and then goes on. In the loop, if Link's on a ladder, it takes away the hover boots. Otherwise, it gives him <whether or not he had them when the loop started>.
So, if he warps away while on a ladder, he won't have the boots. Then, the next copy of th script will check, and see that he doesn't have the boots. Then, it'll give him either no boots, or no boots. Which is the problem.
Now, that said, I suppose I could make this into a global script, which doesn't die with a screen. Let me work on that for a bit...
-
Re: Sidescroll Ladder Script
Couldn't you just make 'hashover' into a global boolean?
-
Re: Sidescroll Ladder Script
I suppose, but I would have to make things complicated, and unless you use the hack you mentioned, you'll lose the hoverboots until the next time you touch a ladder.
In light of this, I think it'll work best as a global script, which I'm just in the middle of preparing for general release.
Edit: I've updated the ladder script. It now uses a global script. More details on global scripts (as I require you to use them) here: Global OnStart Script
-
Re: Sidescroll Ladder Script
Got notified. I will be trying this out shortly. EDIT: Actually, I will be trying out that global script, the update to it.
Umm, please edit the link: "the ladder script." You are missing a "t" in between "c" and "u."
-
Re: Sidescroll Ladder Script
Quote:
(which, by themselves, cannot run more than one frame for no particular reason)
I did see a reason for that once, but I forget what it is now. Might be in the pinned threads in scripting discussion.
Quote:
For your sake any mine,
Should that be and?
And also, howcome you always declare booleans, then set them on the next line?
Code:
bool somethingfoo;
somethingfoo = true;
like that?
Code:
bool somethingfoo = true;
is just as acceptable isn't it?
-
Re: Sidescroll Ladder Script
All the reported typos are fixed (sheesh, my inner-dictionary must be out to lunch or something >_>)
I do variables like that because I thought you couldn't initialize them on the same line.
*tests*
... I coulda sworn I saw an error before... <_< updating scripts
Edit: And, actually, the example you pasted is a typo. Or, a copy-and-pasto, rather. I intended to just have the declaration, before I started copying and pasting stuff in my code blocks -_-'''
Anyway, fixed.
-
Re: Sidescroll Ladder Script
I have learned how a global script does in your neat tutorial site. There are problems with compiliation, here is how I set up your global script.
Code:
bool ladderhashover;
bool onladder;
global script ladder {
void run() {
while(true) {
ladder(98);
Waitframe();
}
}
//Courtesy of Saffith/beefster09
bool isSolid(int x, int y) {
if(x<0 || x>255 || y<0 || y>175) return false;
int mask=1111b;
if(x % 16 < 8)
mask &= 0011b;
else
mask &= 1100b;
if(y % 16 < 8)
mask &= 0101b;
else
mask &= 1010b;
int ret = Screen->ComboS[ComboAt(x, y)] & mask;
return (ret!=0);
}
void ladder(int f) {
int lc;
lc = ComboAt(Link->X+8, Link->Y+15); //for speed
if(Screen->ComboF[lc] == f || Screen->ComboI[lc] == f) {
if(!onladder) {
ladderhashover = Link->Item[I_HOVERBOOTS];
Link->Item[I_HOVERBOOTS] = false;
onladder = true;
}
if(Link->Jump < 0) Link->Jump = 0;
if(Link->InputDown) {
if(!isSolid(Link->X, Link->Y + 16)) Link->Y += 1;
}
if(Link->InputUp) {
if(!isSolid(Link->X, Link->Y - 1)) Link->Y -= 1;
}
} else {
if(onladder) {
Link->Item[I_HOVERBOOTS] = ladderhashover;
onladder = false;
}
}
}
}
The errors in Pass 3 were returned was:
Quote:
TMP, LINE 37: ERROR S10: FUNCTION COMBOAT IS UNDECLARED.
TMP, LINE 45: ERROR S10: FUNCTION COMBOAT IS UNDECLARED.
TMP, LINE 49: ERROR S09: VARIABLE I_HOVERBOOTS IS UNDECLARED.
TMP, LINE 50: ERROR S09: VARIABLE I_HOVERBOOTS IS UNDECLARED.
TMP, LINE 63: ERROR S09: VARIABLE I_HOVERBOOTS IS UNDECLARED.
-
Re: Sidescroll Ladder Script
Tsk, tsk, import "std.zh", my friend.
I missed it from the tutorial, but, it should appear at the top of every .z file...
-
Re: Sidescroll Ladder Script
This is because you didn't tell ZC to import std.zh.
ComboAt is a utility routine, which turns a pixel reference number into coordinates for that pixel, and it's located in std.zh.
Also, why do you have Saffith's bool within your global script?
And how can you declare your own voids?
I don't think I understand voids very well...
-
Re: Sidescroll Ladder Script
I beat you to it, but:
The "isSolid" script is used by my script. That's why it's there. I credited it to Saffith and beefster09 because I didn't write it.
As for it's location, it could be moved to the global namespace (i.e. outside of any script), but it's not that big a deal.
-
Re: Sidescroll Ladder Script
Damn, I didn't notice =P
But won't it never be reached within that global script because of the loop? :confused:
-
Re: Sidescroll Ladder Script
Hooray! It works now. And the flaw with the Z3 (diagnol) movement is corrected, too. Also, no need an extra flag 98 on one tile above the ladder. Well done pkmnfrk.
EDIT: pkmnfrk, don't forget to inform Sillycat2 because he/she is the thread starter in Script Requests.
-
Re: Sidescroll Ladder Script
Quote:
Originally Posted by
Joe123
Damn, I didn't notice =P
But won't it never be reached within that global script because of the loop? :confused:
Hm? It never "gets" to that function, it's called from within ladder(). See, the script contains three functions: "run", "ladder" and "isSolid". "run" is invoked by the game engine, "ladder" and "isSolid" are never invoked directly. They are, however, used by "run", and thus get used.
Quote:
Originally Posted by
zcAmazing
Hooray! It works now. And the flaw with the Z3 (diagnol) movement is corrected, too. Also, no need an extra flag 98 on one tile above the ladder. Well done pkmnfrk.
Not sure, um, how I managed to fix the diagonal movement, but yay!
Quote:
Originally Posted by
zcAmazing
EDIT: pkmnfrk, don't forget to inform Sillycat2 because he/she is the thread starter in Script Requests.
I trust that they are quite able to check this thread themselves, as they have shown the ability to do so in the past.
-
Re: Sidescroll Ladder Script
Quote:
Originally Posted by
pkmnfrk
Hm? It never "gets" to that function, it's called from within ladder(). See, the script contains three functions: "run", "ladder" and "isSolid". "run" is invoked by the game engine, "ladder" and "isSolid" are never invoked directly. They are, however, used by "run", and thus get used.
The Global Script is rather different to ffc scripts then.
When I looked at what you'd written, I read as far as:
Code:
global script ladder {
void run() {
while(true) {
ladder(98);
Waitframe();
}
}
Saw a while(true) loop with a waitframe, and assumed that the script would progress no further, therefore whatever was after that would be obsolete.
Is a void another type of variable like int bool and float then?
-
Re: Sidescroll Ladder Script
I'll answer your first question, uh, first:
Code:
global script ladder {
void run() {
while(true) {
ladder(98);
Waitframe();
}
}
What this is, in effect, doing is:
Code:
global script ladder {
void run() {
while(true) {
int lc = 0;
lc = ComboAt(Link->X+8, Link->Y+15); //for speed
if(Screen->ComboF[lc] == f || Screen->ComboI[lc] == f) {
//...
}
Waitframe();
}
}
If you continue the concept, then at some point, you'll substitute a call to "isSolid" with the contents of the script. (which won't compile, since it isn't the same, but that's beside the point).
Your second question, the nature of void. Void is, well, nothing.
Code:
void foo = ??? //not valid. Can't declare a "nothing" variable
Void comes from C/C++, and means exactly the same thing. It's used to indicate the a function returns void, aka. nothing.
Code:
void foo() { ... } //valid
void bar() { return(???); } //not valid, void is nothing, can't return nothing
Technical side note that should be disregarded entirely if you don't understand it: In C, void still means nothing, but you can also use it to create a pointer that doesn't have any particular type (i.e. it "points to nothing in particular"):
Code:
void * foo = 0x123; //valid, technically
It can't be used directly (you can't deference it, because then you'd have a nothing type), but can be cast to a different type (i.e. a pointer to an integer).
End nerd-note
-
Re: Sidescroll Ladder Script
Ah, so in declaring a void with that chunk of script in, it's like telling ZC to refer to that chunk of script, instead of writing it out within the void run(){}?
And I didn't realise you could refer to different parts of a script that are declared after a loop that the script is stuck on, I thought you had to declare them globally.
Thanks for that.
-
Re: Sidescroll Ladder Script
No. There's no actual replacement going on. When you make a function call, you're telling the scripting engine to temporarily jump to some other part of the overall code, until it gets a command to go back. This is known as the "execution stack" (since, each function "stacks" on top of the last one).
In the case of the ladder script, the stack would look like this:
1. isSolid()
2. ladder()
3. run()
4. the rest of Zelda Classic
-
Re: Sidescroll Ladder Script
So where does it tell it to go back?
Where the void ladder(){} ends?
-
Re: Sidescroll Ladder Script
-
Re: Sidescroll Ladder Script
Ah ok.
Thankyou very much, I've learnt quite a lot just now.
-
Re: Sidescroll Ladder Script
Any time. It's quite confusing, but once you get it, quite rewarding ;)