The Dink Network

upgrading script prevents monster spawning.

June 10th 2012, 04:03 AM
knights.gif
merder
Peasant He/Him Netherlands
The Voice in the back of your head! 
I upgraded a script to include more monsters in later stages but now it stopped working and i've double checked i know i use the correct counter names so now wondering if i missed something(probably just a bracket somewhere which probably is one of the most common script errors just like semicolon's

// guess what i spawn monsters in the dungeons

void main(void)
{
if (&dungeon == 1)
{
if (&special == 0)
{
//ok just arrived so letsspawn some pillbugs

int &temp = create_sprite(295,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

int &temp = create_sprite(295,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

int &temp = create_sprite(511,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

int &temp = create_sprite(511,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

if (random(2,1) == 1)
{
int &temp = create_sprite(332,139,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

}

if (random(2,1) == 1)
{
int &temp = create_sprite(332,220,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

}
&special += 1;
//tells the mod you've been here so the monsters won't respawn again after you've 

left the screen

}
}

if (dungeon == 3)
{

if (&special == 0)
{
//ok just arrived so lets choose what to spawn via randomness

int &who = random(3,1);

if (&who == 1)
// pillies won so lets spawn them
{
int &temp = create_sprite(295,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(295,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(511,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(511,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

if (random(2,1) == 1)
{
int &temp = create_sprite(332,139,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

}

if (random(2,1) == 1)
{
int &temp = create_sprite(332,220,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

}

if (&who == 2)
// half pillies and purple bonca's won so lets spawn them
{
int &temp = create_sprite(295,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(295,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(511,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

int &temp = create_sprite(511,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

if (random(2,1) == 1)
{
int &temp = create_sprite(332,139,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

}

if (random(2,1) == 1)
{
int &temp = create_sprite(332,220,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

}

if (&who == 3)
// bonca's won so lets spawn them
{
int &temp = create_sprite(295,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

int &temp = create_sprite(295,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

int &temp = create_sprite(511,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

int &temp = create_sprite(511,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

if (random(2,1) == 1)
{
int &temp = create_sprite(332,139,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

}

if (random(2,1) == 1)
{
int &temp = create_sprite(332,220,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

}

&special += 1;
//tells the mod you've been here so the monsters won't respawn again after you've 

left the screen

}


wonder what causes it to not work because initially it did work
June 10th 2012, 04:13 AM
dinkdead.gif
The problem is probably line 62:
if (dungeon == 3)
should be
if (&dungeon == 3)

Maybe the comments too: "left the screen" should be commented out but isn't.

By the way, the "int" is only needed the first time you make the variable, every other time you can just do
&temp = create_sprite(etc);
But it shouldn't cause a problem.

Edit:
Also, after
if (dungeon == 3)
I count 4 unclosed brackets...
June 10th 2012, 05:20 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
It does sometimes cause a problem if you reuse int. I don't know the details, but I remember having to change that in a few scripts before... Wish I could remember what it caused though. Best practice is to never do it anyway.
June 10th 2012, 05:22 AM
knights.gif
merder
Peasant He/Him Netherlands
The Voice in the back of your head! 
ok will see if it helps and the Left the screen part is copy and paste edits from windows initial script has it in one line(wonder why windows does those edits even if not needed))
June 10th 2012, 06:26 AM
knights.gif
merder
Peasant He/Him Netherlands
The Voice in the back of your head! 
updates syntax highlithging for notepad++ and the new feature of collapsing helped tons so fixed bracket error and th missed &
and it is fixed

so her is the fixed code and doubt i've missed anything now (as usual feel free too use in your mods with proper credits and if used i recommend adding new sectiosns like i will ofr when i have new bosses scripted for the other dungeons and don't forget to chage counter names or add the globals i've used(bet you can tell their names by just looking at script .

Also Kyle the script i set up so it works only once per chosen dungeon floor so don't think the initiating should be that much of a problem.

// guess what i spawn monsters in the dungeons

void main(void)
{
if (&dungeon == 1)
{
if (&special == 0)
{
//ok just arrived so letsspawn some pillbugs

int &temp = create_sprite(295,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

int &temp = create_sprite(295,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

int &temp = create_sprite(511,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

int &temp = create_sprite(511,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

if (random(2,1) == 1)
{
int &temp = create_sprite(332,139,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

}

if (random(2,1) == 1)
{
int &temp = create_sprite(332,220,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill");

}
&special += 1;
//tells the mod you've been here so the monsters won't respawn again after you've left the screen

}
}

if (&dungeon == 3)
{

if (&special == 0)
{
//ok just arrived so lets choose what to spawn via randomness

int &who = random(3,1);

if (&who == 1)
// pillies won so lets spawn them
{
int &temp = create_sprite(295,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(295,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(511,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(511,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

if (random(2,1) == 1)
{
int &temp = create_sprite(332,139,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

}

if (random(2,1) == 1)
{
int &temp = create_sprite(332,220,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

}
}
if (&who == 2)
// half pillies and purple bonca's won so lets spawn them
{
int &temp = create_sprite(295,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(295,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

int &temp = create_sprite(511,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

int &temp = create_sprite(511,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

if (random(2,1) == 1)
{
int &temp = create_sprite(332,139,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pill1");

}

if (random(2,1) == 1)
{
int &temp = create_sprite(332,220,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

}
}

if (&who == 3)
// bonca's won so lets spawn them
{
int &temp = create_sprite(295,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

int &temp = create_sprite(295,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

int &temp = create_sprite(511,160,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

int &temp = create_sprite(511,230,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

if (random(2,1) == 1)
{
int &temp = create_sprite(332,139,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

}

if (random(2,1) == 1)
{
int &temp = create_sprite(332,220,9,131,1);

sp_dir(&temp,1);

sp_script(&temp,"en-pbon");

}
}

&special += 1;
//tells the mod you've been here so the monsters won't respawn again after you've left the screen

}