PDA

View Full Version : Some questions about Global ZScript scripts....



Nimono
02-06-2007, 11:45 PM
Okay, here's my questions....

1: When I make a Global Script, does it ALWAYS run the moment the game starts?
2: Are there any commands and stuff that are global-script-exclusive?
3: Is there a way to make a Global Script run and stop whenever you want it?

Yeeeah... Stungun, at PureZC, mentioned a way to make a Metroid-style escape timer. Only problem is..... I need it to begin at a certain point and end at another certain point. If they Global Scripts only run when you start a quest.... That will really ruin the quest. Thanks for the help. :)

Grayswandir
02-07-2007, 07:55 AM
Take a look at my darkform script. It has the global script running constantly in the background, but it doesn't do anything until it is activated by a function call from the item script. So in this case, you'd probably want something like:


global script foo() {

int time = 0;
bool time_on = false;

void run() {
While(true) {
if(time_on) {
time += 1;
if(time >= 500) {
// Do Something
}
}
Waitframe();
}
}

void StartTimer() {
time_on = true;
}
}


You'd just have something say foo.StartTimer(); when you want the timer to begin.

Nimono
02-08-2007, 01:31 PM
.....That doesn't exactly help me much. Thanks anyways, though....

Grayswandir
02-08-2007, 09:03 PM
3: Is there a way to make a Global Script run and stop whenever you want it?

Yeeeah... Stungun, at PureZC, mentioned a way to make a Metroid-style escape timer. Only problem is..... I need it to begin at a certain point and end at another certain point. If they Global Scripts only run when you start a quest.... That will really ruin the quest. Thanks for the help. :)

Here, this is what I meant. Using the below code:

Use the script foo as one of your global scripts.

Make an ffc in the room which you want the timer to start in. Give it the ffc script start_timer, with the following argument values:
D0: How long before the timer runs out.
D1: Which DMap Link will warp to when the timer runs out.
D2: Which Screen Link will warp to when the timer runs out.

Make an ffc in the room which you want the timer to stop in. Give it the ffc script stop_timer.



global script foo {

int time = 0;
int max_time = 0;
int warp_dmap = 0;
int warp_screen = 0;
bool time_on = false;

void run() {
While(true) {
if(time_on) {
time += 1;
if(time >= max_time) {
Link->Warp(warp_dmap, warp_screen);
StopTimer();
}
}
Waitframe();
}
}

void StartTimer(int time, int dmap, int screen) {
time_on = true;
time = 0;
max_time = time;
warp_dmap = dmap;
warp_screen = screen;
}

void StopTimer() {
time_on = false;
}
}

ffc script start_timer {
void run(int time, int dmap, int screen) {
foo.StartTimer(time, dmap, screen);
}
}

ffc script stop_timer {
void run() {
foo.StopTimer();
}
}




This should work, but I haven't tested it. So basically, upon entering the room with the first ffc, you have x amount of time to reach the room with the second ffc, or Link will warp to the specified room.



Hopefully, this is what you're looking for. ;)

Nimono
02-08-2007, 09:22 PM
No, I just want to know how to make a script start when a certain script starts it (and at no other time), what commands are used to start it, and how to stop it. That's ALL. I can get the timer itself done myself. :)

Grayswandir
02-08-2007, 09:30 PM
That's ALL. I can get the timer itself done myself. :)


Certainly. I just thought that the timer would make a good example on how to start and stop a script.

Nimono
02-08-2007, 10:20 PM
Certainly. I just thought that the timer would make a good example on how to start and stop a script.

Uhh.... That meant "Please tell me how to do that". XD

Revfan9
02-08-2007, 10:20 PM
Use the variable gd255. When it is 1, start the timer.