PDA

View Full Version : Global variables, Global scripts, Quick-loading ffc's->thisCombo, and a Kitchen sink!



Gleeok
09-20-2007, 07:02 AM
Alright so here's the clock script....*ahem*, the Doomsday clock script. I figured two scripts would be necessary, a global, and an ffc script, to implement the "timer" portion and the clock portion...anyway;



global script Doomsday{

void run(){

int doom = 648000;

int sec_combo = 9000;
int min_combo = 9080;
int hour_combo = 9120;
int sec_count = 0;
int min_count = 0;
int hour_count = 0;
ffc hour = Screen->LoadFFC(30);
ffc minutes = Screen->LoadFFC(31);
ffc seconds = Screen->LoadFFC(32);

while(true){
if (doom >=1){
Waitframes(60);
doom--;
sec_count++;
sec_combo++;
if (sec_count == 60){
sec_count = 0;
sec_combo = 9000;
min_combo++;
min_count++;
}
if (min_count == 60){
min_count = 0;
min_combo = 9080;
hour_count++;
hour_combo++;
}

} else {
Link->Pitwarp(255,00);
Game->PlaySound(27);
Waitframes(1800);
Quit();
}
}
}
}

ffc script timer{
void run(){
int sec_combo = 9000;
int min_combo = 9080;
int hour_combo = 9120;

int hourX = this_ffc->x;
int hourY = this_ffc->y;
int minX = this_ffc->x+16;
int minY = this_ffc->y;
int secX = this_ffc->x+32;
int secY = this_ffc->y;

So many questions...

Anyway you can see what i'm trying to do here, and am wondering if

1)The int in the global script should go before the void run(), (or ffc script?)

2) What, if anything, is unnecesary or should be added, in particular the ffc script. I'm trying to make it super easy to use, ie everything runs itself, just let the scripts do all the work. :D

3) How exactly does the relationship between the global and ffc script work when (automatically) changing the combo of said ffc based on my variable xxx_combo, and what command is needed?

...I guess it's mainly setting the combo ID to match the global stuff. This is doable with a global script though, isn't it?

ShadowMancer
09-20-2007, 03:45 PM
)The int in the global script should go before the void run(), (or ffc script?)
actually if you want these vars to be global you need to put them outside the scripts altogether.


import std.zh
int doom = 648000;
int sec_combo = 9000;
int min_combo = 9080;
int hour_combo = 9120;
int sec_count = 0;
int min_count = 0;
int hour_count = 0;

global script Doomsday{

void run(){

//etc...




3) How exactly does the relationship between the global and ffc script work when (automatically) changing the combo of said ffc based on my variable xxx_combo, and what command is needed?
Your varible
ffc hour = Screen->LoadFFC(30);
is the pointer to the FFC, so if you want to change the combo of the hour FFC then you would do:
hour->Data = n
so actually you would not need an FFC script at all, just FFCs, the global script can control everything, and the FFCs are just there for graphics (You could also use drawing routines but I have not experminted with them enough to give you any advice yet) and also makeing the FFCs move is easy. I assume you want the FFC hands to move in a circle so use a circle movemnt routine (there is one in the forums somewhere too lazy to look myself right now :p)

Gleeok
09-20-2007, 11:53 PM
Thanks ShadowMancer, I think i'm understanding global stuff alot better meow. Also if anyone is wondering why this thread is named very stupidly, it's because I was half asleep and originally had like 2 more different scripts to post. @_@

So check it out, it works fine as one global script.


import "std.zh"

global script Doomsday{

void run(){

int doom = 648000;

int sec_combo = 9000;
int min_combo = 9080;
int hour_combo = 9120;
int sec_count = 0;
int min_count = 0;
int hour_count = 0;
ffc hour = Screen->LoadFFC(30);
ffc minutes = Screen->LoadFFC(31);
ffc seconds = Screen->LoadFFC(32);

while(true){
hour->X = 208;
hour->Y = 0;
minutes->X = 224;
minutes->Y = 0;
seconds->X = 240;
seconds->Y = 0;
if (doom >=1){
Waitframes(60);
doom--;
sec_count++;
sec_combo++;
seconds->Data = sec_combo;
if (sec_count == 60){
sec_count = 0;
sec_combo = 9000;
min_combo++;
min_count++;
minutes->Data = min_combo;
}
if (min_count == 60){
min_count = 0;
min_combo = 9080;
hour_count++;
hour_combo++;
hour->Data = hour_combo;
}

} else {
Link->PitWarp(255,00);
Game->PlaySound(27);
Waitframes(1800);
Quit();
}
}
}

Haha! Thanks to scripting, one could easily make an awesome dungeon crawler quest in only a fraction of the time compareed to 2.10. Weeks even. As soon as I finish these scripts i'll put that statement to the test. :D


-Anyway :with this script: .....one major problem....How do I make it carry-over saved games and deaths?!?

and.. this line:
int doom = 648000; Gets a T20: truncation error even though it compiles fine. What's that about DD?

ShadowMancer
09-21-2007, 09:55 PM
How do I make it carry-over saved games and deaths?!?
just make sure the int doom is a global varible because globals Do save between um saves now :p (Thanks to DD)


Gets a T20: truncation error even though it compiles fine. What's that about DD?




T20: Truncation of constant x.

Both floats and ints can only be specified to four places of decimal precision. Any extra digits are simply ignored by the compiler, which then issues this warning.


Like it says it is just a warning, but that is odd I don't see where any decimal places are used at all unless I am understanding this error wrong.


Also if anyone is wondering why this thread is named very stupidly, it's because I was half asleep and originally had like 2 more different scripts to post. @_@
Ah I like the way you name things crazy like that give me a good :laughing: now and then.

Gleeok
09-21-2007, 11:42 PM
Ah, of course. thanks. :)
I'll test that out..but won't the variable int doom = 648000 be reset to 64800, or does the doom-- permanantly store the changes to the global? Well i'll just have to test it then. ;)

Oh, wait...I would have to make them alll global vars because the timer would get reset too.....ah krap, I hope this works...well, I do know one way around this...if Link->save>0 ll Link->death>0{ Link pitWarp->Game Over.....

...well i'll consider that a last resort.:eyebrow:

ShadowMancer
09-22-2007, 08:44 PM
int doom = 6480;
int mutiplier = 100;
run your for loop, each time doom reaches 0, check to see if mutiplier > 0 else mutiplier -=1 doom = 6480. once doom == 0 && mutiplier == 0 then DISTROY THE FREAKIN WORLD!!!! got it?

Gleeok
09-28-2007, 07:05 AM
int doom = 6480;
int mutiplier = 100;
run your for loop, each time doom reaches 0, check to see if mutiplier > 0 else mutiplier -=1 doom = 6480. once doom == 0 && mutiplier == 0 then DISTROY THE FREAKIN WORLD!!!! got it?


Got it :toast:

Gleeok
10-04-2007, 03:34 AM
*EDIT* Ahahaha!! Nevermind that. It works. Here's something cool:


I now have a system for exp points!



...teehee......:rolleyes:


.