PDA

View Full Version : Global scripts and waitframe



Russ
11-25-2007, 06:34 PM
Is there any possbile way to get waitframe to work with global scripts? I am tying to make a script tha checks if Link is on a certain dmap, and if so, waits for a few minutes, then warps Link to another dmap. Accroding to the zscript file, waitframe does not work with global scripts. Is there any way to get my script to work?

DarkDragon
11-25-2007, 07:03 PM
Not currently.

You can, however, use a global variable to count the number of frames that have gone by, and warp when it reached a critical amount.

Or use carryover FFC scripts.

Joe123
11-25-2007, 07:14 PM
You don't have Waitframe(); in the Global Script? eh?
It's in mine :confused:

Russ
11-25-2007, 07:20 PM
Not currently.

You can, however, use a global variable to count the number of frames that have gone by, and warp when it reached a critical amount.

Or use carryover FFC scripts.
I'll use the global variable. So I would just have in increase by one each frame, and then warp Link when the count gets high enough, correct?

DarkDragon
11-25-2007, 07:24 PM
You're right. It all depends on which global script you use.

Two of them only execute when the quest is started or loaded. You can't Waitframe() in those.
The other executes each frame, and can use Waitframe().

So you'll want something like


global script warper {
void run() {
int frames=0;
while(true)
{
if(Game->GetCurDMap() == whatever)
{
if(frames > whatever)
Link->Warp(whereever);
else
frames++;
}
else
frames = 0;

Waitframe();
}
}
}

Joe123
11-25-2007, 07:25 PM
does the Global Script loop automatically or something?
I'm very confused.

DarkDragon
11-25-2007, 07:30 PM
Which global script?

Two of them (I think the first and third slot, but better go look it up ;) ) execute exactly one frame, when the quest is first started (slot 1) and whenever the quest is loaded (slot 3?). The other (slot 2?) executes once per frame, like FFC scripts.

Joe123
11-25-2007, 07:38 PM
ahhh! I had no idea.
Could this be noted in the compiler?
So there's no need to have a while loop in the Global Script in slot 2?

DarkDragon
11-25-2007, 07:45 PM
No, you do.
I just wrote a buggy example script. ;) Fixing now.

Russ
11-25-2007, 07:58 PM
You're right. It all depends on which global script you use.

Two of them only execute when the quest is started or loaded. You can't Waitframe() in those.
The other executes each frame, and can use Waitframe().

So you'll want something like


global script warper {
void run() {
int frames=0;
while(true)
{
if(Game->GetCurDMap() == whatever)
{
if(frames > whatever)
Link->Warp(whereever);
else
frames++;
}
else
frames = 0;

Waitframe();
}
}
}

Okay. Thanks for the help.

Edit: I edited your script to suite my needs. Now I am getting a compiler error. Here is the script:

global script warper {
void run() {
int frames=0;
int daydmap1= 0;
int nightdmap1= 1;
int screen

while(true)
{
if(Game->GetCurDMap() == daydmap1)
{
if(frames > 7200)
Game->GetCurScreen() = screen;
Link->PitWarp(nightdmap1, screen);
else
frames++;
}
else
frames = 0;

Waitframe();
}
}
}
Right now all I want it to do is check to see if Link is on the daytime overworld, wait 2 minutes, and then send direct warp him to the same screen of the same map, but on a night time dmap, on the same map. I am getting the error from the compiler:
LINE 8: sYNTAX ERROR, UNEXPECTED WHILE , EXPECTING ASSIGN, ON TOKEN WHILE
FATAL ERROR POO; CAN'T OPEN OR PARSE INPUT FILE!

Anyone able to tell what I did wrong?

Russ
11-26-2007, 07:04 PM
Sorry for the double post, but I guess nobody noticed I edited the post before. I edited the script, but it doesn't compile. Can somebody please help me. Details in above post.

DarkDragon
11-26-2007, 07:23 PM
You need to finish the line that begins "int screen".

Joe123
11-26-2007, 07:31 PM
There are no braces around the commands you're using within the else loops.

Russ
11-27-2007, 01:35 AM
Okay, I am still having some minor problems. What I want the script to do is check to see if Link is on the dmap, wait 2 minutes, then send him to the twilight dmap. Then wait 17 seconds, then send him to the night dmap. The wait 2 minutes, then send him to the morining dmap. The wait 17 seconds, the send him to the day dmap. I starts out fine, it waits two minutes, then sends him to the twilight dmap. But after that, it won't send him to the night dmap. And if I start out on the night dmap, it won;t send him to the morning dmap. Here is the script:



global script warper {
void run() {
int frames=0;
int daydmap1= ;
int daydmap2= ;
int twilightdmap1= ;
int twilightdmap2= ;
int nightdmap1= ;
int nightdmap2= ;
int morningdmap1= ;
int morningdmap2= ;
int screen;
while(true)
{
if(Game->GetCurDMap() == daydmap1)
{
if(frames > 7200) {
screen = Game->GetCurScreen();
Link->PitWarp(twilightdmap1, screen);
}
else {
frames++;
}
}
else {
frames = 0;
}

Waitframe();
}
frames = 0;
while(true)
{
if(Game->GetCurDMap() == twilightdmap1)
{
if(frames > 1200) {
screen = Game->GetCurScreen();
Link->PitWarp(nightdmap1, screen);
}
else {
frames++;
}
}
else {
frames = 0;
}

Waitframe();
}
frames = 0;
while(true)
{
if(Game->GetCurDMap() == nightdmap1)
{
if(frames > 7200) {
screen = Game->GetCurScreen();
Link->PitWarp(morningdmap1, screen);
}
else {
frames++;
}
}
else {
frames = 0;
}

Waitframe();
}
frames = 0;
while(true)
{
if(Game->GetCurDMap() == morningdmap1)
{
if(frames > 1200) {
screen = Game->GetCurScreen();
Link->PitWarp(daydmap1, screen);
}
else {
frames++;
}
}
else {
frames = 0;
}

Waitframe();
}
frames = 0;
while(true)
{
if(Game->GetCurDMap() == daydmap2)
{
if(frames > 7200) {
screen = Game->GetCurScreen();
Link->PitWarp(twilightdmap2, screen);
}
else {
frames++;
}
}
else {
frames = 0;
}

Waitframe();
}
frames = 0;
while(true)
{
if(Game->GetCurDMap() == twilightdmap2)
{
if(frames > 1200) {
screen = Game->GetCurScreen();
Link->PitWarp(nightdmap2, screen);
}
else {
frames++;
}
}
else {
frames = 0;
}

Waitframe();
}
frames = 0;
while(true)
{
if(Game->GetCurDMap() == nightdmap2)
{
if(frames > 7200) {
screen = Game->GetCurScreen();
Link->PitWarp(morningdmap2, screen);
}
else {
frames++;
}
}
else {
frames = 0;
}

Waitframe();
}

frames = 0;
while(true)
{
if(Game->GetCurDMap() == morningdmap2)
{
if(frames > 1200) {
screen = Game->GetCurScreen();
Link->PitWarp(daydmap2, screen);
}
else {
frames++;
}
}
else {
frames = 0;
}

Waitframe();
}
}
}


I have two day, two twilight, etc. dmaps because I have two area I want affected. So, is there any obvious mistake I am overlooking?

Gleeok
11-27-2007, 01:56 AM
Hrm, that's alot of while(true) loops. It might be easier to go through if there was less material.

Or maybe seperate them into condition loops. ie:


while(Game->GetCurDMap() == morningdmap1){
if(frames == 1200) {
screen = Game->GetCurScreen();
Link->PitWarp(daydmap1, screen);
frames = 0;
}
Waitframe(); frames++;
}


It's just hard to read for me if you don't use Tab. :p

Joe123
11-27-2007, 04:00 AM
I'd be very wary of trying to put in more than one while loop.

Personally, I'd put them all in one while loop, and just have ifs to change where Link is (so set the ifs to be doing what your whiles are at the moment, but inside one while).

And yeah, people who use spacebar instead of Tab should have their hands cut off =P

Russ
11-27-2007, 11:16 AM
I'd be very wary of trying to put in more than one while loop.

Personally, I'd put them all in one while loop, and just have ifs to change where Link is (so set the ifs to be doing what your whiles are at the moment, but inside one while).

And yeah, people who use spacebar instead of Tab should have their hands cut off =P
I had all the while lopps because of the way I wrote the code. First, I took DarkDragon's basic code frame. Then, I edited it to fit my needs. The, I copied and pasted it seven times, just changing the variables.

I'll try Gleeok's method and see if that works.