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 ;)