Reply to 17-2=-31??? Probably some variable-exchange thing again...
If you don't have an account, just leave the password field blank.
I'm trying to script torches that go out one minute after they've been set on fire. And they have to remember when they are set on fire, so, for example: You light them on t=0, then you wait 15 seconds and go to another screen, then t=15. You wait 15 seconds there and go back, t=30. You wait 30 more seconds and it stops burning. I'm using this script for time-management:
void main( void )
{
loop:
wait(1000);
&duntimer += 1;
if (&player_map < 353)
{
&duntimer = 0;
kill_this_task();
}
goto loop;
}
In which &duntimer is a global. The if line is there because it should stop counting when in a specific area. I don't think the variable-value limit is relevant here, because you have to be really sick when you spend that much time while the script is active. It basically adds 1 to the &duntimer for every second since it is spawned, which happened in a base script.
When you've launched a fireball at it, the dam-fire checks if the sp_gold() value is 10, and if so, it runs the burn(void) proc, which looks like this:
void burn( void )
{
int &junk = sp_editor_num(¤t_sprite);
editor_seq(&junk, &duntimer);
int &crap = &duntimer;
sp_gold(¤t_sprite, 0);
sp_pseq(¤t_sprite, 916);
sp_brain(¤t_sprite, 6);
sp_seq(¤t_sprite, 916);
sp_frame(¤t_sprite, 1);
goto timecheck;
}
It uses Pauls Script trick with editor seqs/frames to let the sprite remember when it was put on fire, it changes the graphic to a burning torch and goes to the timecheck label:
timecheck:
&crap = editor_seq(&junk, -1);
wait(100);
&brap = &duntimer;
&brap -= &crap;
say("Global time: &duntimer. Local time: &crap. Difference time: &duntimer - &crap = &brap.",¤t_sprite);
if (&brap < 60)
{
goto timecheck;
}
unburn();
This is also a constant loop, unless &brap reaches 60. Then the script runs the unburn(void) proc:
void unburn( void )
{
int &junk = sp_editor_num(¤t_sprite);
sp_gold(¤t_sprite, 10);
sp_brain(¤t_sprite, 0);
sp_pseq(¤t_sprite, 850);
sp_pframe(¤t_sprite, 23);
editor_seq(&junk, 0);
&crap = 0;
}
Maybe goto's work better than this proc() using, but my problem occurs even before this stage. As you can see I've added some dev-text in the timecheck proc. But now the weird thing is, the torch says: "Global time: 17. Local time: 2. Difference time: 17 - 2 = -32". That in itself is pretty weird, but when I've got more torches on one screen, the "Local time" doesn't matter. All "Difference times" are the same (they count, too, just like the Global time).
Anyone knows what's happening here? If it doesn't even work when staying on the screen, how am I supposed to make it work if you change screens?
Oh, as a sidenote, does get_sprite_with_this_brain() work with "new" brains, like brain 23 or something?
void main( void )
{
loop:
wait(1000);
&duntimer += 1;
if (&player_map < 353)
{
&duntimer = 0;
kill_this_task();
}
goto loop;
}
In which &duntimer is a global. The if line is there because it should stop counting when in a specific area. I don't think the variable-value limit is relevant here, because you have to be really sick when you spend that much time while the script is active. It basically adds 1 to the &duntimer for every second since it is spawned, which happened in a base script.
When you've launched a fireball at it, the dam-fire checks if the sp_gold() value is 10, and if so, it runs the burn(void) proc, which looks like this:
void burn( void )
{
int &junk = sp_editor_num(¤t_sprite);
editor_seq(&junk, &duntimer);
int &crap = &duntimer;
sp_gold(¤t_sprite, 0);
sp_pseq(¤t_sprite, 916);
sp_brain(¤t_sprite, 6);
sp_seq(¤t_sprite, 916);
sp_frame(¤t_sprite, 1);
goto timecheck;
}
It uses Pauls Script trick with editor seqs/frames to let the sprite remember when it was put on fire, it changes the graphic to a burning torch and goes to the timecheck label:
timecheck:
&crap = editor_seq(&junk, -1);
wait(100);
&brap = &duntimer;
&brap -= &crap;
say("Global time: &duntimer. Local time: &crap. Difference time: &duntimer - &crap = &brap.",¤t_sprite);
if (&brap < 60)
{
goto timecheck;
}
unburn();
This is also a constant loop, unless &brap reaches 60. Then the script runs the unburn(void) proc:
void unburn( void )
{
int &junk = sp_editor_num(¤t_sprite);
sp_gold(¤t_sprite, 10);
sp_brain(¤t_sprite, 0);
sp_pseq(¤t_sprite, 850);
sp_pframe(¤t_sprite, 23);
editor_seq(&junk, 0);
&crap = 0;
}
Maybe goto's work better than this proc() using, but my problem occurs even before this stage. As you can see I've added some dev-text in the timecheck proc. But now the weird thing is, the torch says: "Global time: 17. Local time: 2. Difference time: 17 - 2 = -32". That in itself is pretty weird, but when I've got more torches on one screen, the "Local time" doesn't matter. All "Difference times" are the same (they count, too, just like the Global time).
Anyone knows what's happening here? If it doesn't even work when staying on the screen, how am I supposed to make it work if you change screens?
Oh, as a sidenote, does get_sprite_with_this_brain() work with "new" brains, like brain 23 or something?