Script problem, won't modify variable
This script is spawned when you begin a new game (start1.c); I've also tried spawning it via key script. Everything works, as far as I can tell, except &stamina += 1; doesn't happen for some reason (it remains at 0 as preset in main.c). Dink says the number so that verifies that the condition is working properly. I've tried replacing it with other variables and they didn't change either.
//stamina.c
//&stamina is a global variable
//replenishes stamina var over time
void main ()
{
wait(1);
script_attach(1000);
int &shownum = say_xy("`% Stamina: &stamina", -235, -0);
sp_kill(&shownum, 0);
loop:
wait(200);
if (&stamina < 100)
{
&stamina += 1;
say("&stamina",1);
goto refresh;
}
goto loop;
}
void refresh ()
{
refresh:
sp_active(&shownum,0);
&shownum = say_xy("`% Stamina: &stamina", -235, -0);
sp_kill(&shownum, 0);
goto loop;
}
//stamina.c
//&stamina is a global variable
//replenishes stamina var over time
void main ()
{
wait(1);
script_attach(1000);
int &shownum = say_xy("`% Stamina: &stamina", -235, -0);
sp_kill(&shownum, 0);
loop:
wait(200);
if (&stamina < 100)
{
&stamina += 1;
say("&stamina",1);
goto refresh;
}
goto loop;
}
void refresh ()
{
refresh:
sp_active(&shownum,0);
&shownum = say_xy("`% Stamina: &stamina", -235, -0);
sp_kill(&shownum, 0);
goto loop;
}
I tested the script, and it works as it's supposed to. The problem must be somewhere else.
Wonder why it wouldn't work for me. hm.. I ended up starting over from scratch and re-made it, with tweaks and some bug fixes. So far this works perfectly.
//stamina.c
//spawned at start
//regenerate stamina
void main ()
{
wait(1);
script_attach(1000);
int &shownum;
int &showtit;
int &mapbug;
loop:
&mapbug = &player_map;
wait(66);
if (&stamina < 100)
{
&stamina += 2;
if (&stamina > 100)
&stamina = 100;
}
&showtit = say_xy("`% Stamina:", -255, 383);
if (&mapbug == &player_map)
sp_kill(&shownum,66);
&shownum = say_xy("`% &stamina", -203, 383);
goto loop;
}
//stamina.c
//spawned at start
//regenerate stamina
void main ()
{
wait(1);
script_attach(1000);
int &shownum;
int &showtit;
int &mapbug;
loop:
&mapbug = &player_map;
wait(66);
if (&stamina < 100)
{
&stamina += 2;
if (&stamina > 100)
&stamina = 100;
}
&showtit = say_xy("`% Stamina:", -255, 383);
if (&mapbug == &player_map)
sp_kill(&shownum,66);
&shownum = say_xy("`% &stamina", -203, 383);
goto loop;
}
Edit: There was another script here, but I found out it was the same problem (a variable change not being processed.) I did the script over from scratch and it's exactly the same.
Does anyone know what may be causing this?
Does anyone know what may be causing this?
Do you have another variable that starts with the same 4 letters?
Well I copied from some other script and used as a blank template, could it be that there was an issue with the file itself? When I did both scripts over I ended up using different base scripts from the original ones I used and it ended up working.
I don't think it has anything to do with the variables themselves, because I tried substituting them with other variables like life/strength/magic and it was only one instance of the variable being changed in the script that didn't work.
I don't think it has anything to do with the variables themselves, because I tried substituting them with other variables like life/strength/magic and it was only one instance of the variable being changed in the script that didn't work.
Oh, when you said "exactly the same" I thought the bug was still there, not it was the same as last time (i.e. rewriting worked). What I originally thought was that there was some wacky character. I think there is more than one ENTER character - maybe Dink only recognises one of them. That would explain why it worked for scratcher (presumedly it was lost when you or he copy&pasted it). So just chalk it up to the file as you suggest..