insanoflex@Posted: Mon Nov 01, 2010 9:40 pm :
Im using a script to trigger radio entities in my map. But when I go to run my map, I am getting some pretty strange compile errors. First, when I used a switch statement for the different radio transmissions, I got an error "Switch is not a type". I changed them to if statements. Started to work, so I changed a few things in it. Now Im getting a "If is not a type" error. Also, am I not allowed to declare int, only float?

code here (sorry kinda messy). The first part is used for some ragdolls.
Code:
/************************************
* Map Scripts for Crewsquarters
***********************************/

//this script launches the two skeletons, revealing some enemies
//location: maintenance access level 1

void ragdollthrow1 ()
{
   $ragdoll1mover.time(.1);
   $ragdoll1mover.moveTo ( $ragdoll1dest );
   $ragdoll2mover.time(.1);
   $ragdoll2mover.moveTo ( $ragdoll2dest );
   sys.waitFor ($ragdoll1mover);
   $ragdoll1.unbind();
   $ragdoll2.unbind();
}

//this script moves the corpse to the pentagram and throws it at
//the ceiling panel, blocking off the room for the fight
//location: breakroom level 1

void ragdollthrow2 ()
{
   //first, bind the corpse to the mover
   sys.trigger ( $ragdollthrow2_soundstinger );
   $ragdoll3.bind( $ragdoll3mover );
   sys.wait(2);

   //move to the pentagram
   sys.trigger ( $ragdollthrow2_soundcrying );
   $ragdoll3mover.time(.5);
   $ragdoll3mover.moveTo( $ragdoll3mover_dest1 );
   sys.waitFor ($ragdoll3mover);
   sys.wait(1);
   $ragdoll3mover.moveTo( $ragdoll3mover_dest2 );
   sys.waitFor ($ragdoll3mover);

        //trigger the pentagram
        sys.trigger( $ragdollthrow2_soundchant );
        sys.trigger( $ragdollthrow2_soundstinger2 );
        sys.wait(1);
   sys.trigger( $ragdollthrow2_pentagram );
   sys.wait(5);
   sys.trigger( $ragdollthrow2_pentagram );

   //move to the ceiling panel
   sys.trigger( $ragdollthrow2_light1 );
        sys.trigger( $ragdollthrow2_light2 );
        sys.trigger( $ragdollthrow2_light3 );
   $ragdoll3mover.moveTo( $ragdoll3mover_dest3 );
   sys.waitFor ($ragdoll3mover);
   $ragdoll3mover.moveTo( $ragdoll3mover_dest4 );
   sys.waitFor ($ragdoll3mover);
   $ragdoll3.unbind();
   sys.trigger( $ragdollthrow2_soundmetal2 );

   //the ceiling panel rotates because of the hit
   $ragdollthrow2_ceilingpanel.time(.4);
   $ragdollthrow2_ceilingpanel.accelTime(.1);
   $ragdollthrow2_ceilingpanel.decelTime(.2);
   $ragdollthrow2_ceilingpanel.rotateOnce( '0 0 90' );
   sys.waitFor( $ragdollthrow2_ceilingpanel );
   sys.trigger( $ragdollthrow2_soundmetal1 );

   //trigger monsters
   sys.trigger( $ragdollthrow2_monstertele );   
}

//This script calls a random radio sound each time it
//is triggered.
//location: whole map

void random_radio ()
{
   float transmission;
   transmission = sys.random(8) + 1;
   sys.print ("triggering radio with value ");
   sys.print (transmission);
   
   if (transmission >= 1)
   {
      if (transmission <= 2)
         sys.trigger($radio_random1);
   }
   if (transmission >= 2)
   {
      if (transmission <= 3)
         sys.trigger($radio_random2);
   }
   if (transmission >= 3)
      if (transmission <= 4)
         sys.trigger($radio_random3);
   }
   if (transmission >= 4)
   {
      if (transmission <= 5)
         sys.trigger($radio_random4);
   }
   if (transmission >= 5)
   {
      if (transmission <= 6)
         sys.trigger($radio_random5);
   }
   if (transmission >= 6)
   {
      if (transmission <= 7)
         sys.trigger($radio_random6);
   }
   if (transmission >= 7)
   {
      if (transmission <= 8)
         sys.trigger($radio_random7);
   }
   if (transmission >= 8)
   {   
      if (transmission <= 9)
         sys.trigger($radio_random8);
   }
}

//This is the radio sound script that calls right after
//the initial invasion.
//location: whole map

void radio_start ()
{
   //We have a codered
   sys.trigger ($radio_codered);
   sys.wait (7);
   
   //Fall back to HQ
   sys.trigger ($radio_fallback);
   sys.wait (10);

   //random radio chatter
   sys.trigger ($radio_someguydying);
   sys.wait (10);

   sys.trigger ($radio_screaming);
   sys.wait (10);

   sys.trigger ($radio_overrun);
   sys.wait (11);
   
   //Say again, fall back to regroup
   sys.trigger ($radio_fallbackrepeat);
   sys.wait (10);

   //calling the random radio script
   float radio_count;
   float max_radio_count;
   radio_count = 0;
   random_radio();
   max_radio_count = sys.random(1)+1;

   while (radio_count < max_radio_count)
   {
      sys.wait (sys.random(4) +20);
      radio_count += 1;
      random_radio();
   }

   //Give sitreps
   sys.trigger ($radio_givesitreps);
   sys.wait (5);
   
   //Sitreps
   sys.trigger ($radio_sitrep1);
   sys.wait (6);
   sys.trigger ($radio_sitrep2);
   sys.wait (14);
   sys.trigger ($radio_sitrep3);
   sys.wait (6);

   //calling the random radio script
   radio_count = 0;
   random_radio ();
   max_radio_count = sys.random(4)+9;
      
   while (radio_count < max_radio_count )
   {
      sys.wait (sys.random(4) +20);
      radio_count += 1;
      random_radio();
   }
}


   
   
}



Sikkpin@Posted: Mon Nov 01, 2010 11:07 pm :
Looks like you are missing the opening bracket here:
Code:
   if (transmission >= 3)
      if (transmission <= 4)
         sys.trigger($radio_random3);
   }

Also, you can cast the random value to an integer like so:
Code:
transmission = int( sys.random(8) + 1 )
This way you only have to do your if's like this:
Code:
if ( transmission == 1 )
    sys.trigger( $radio_random1 );
...etc...



The Happy Friar@Posted: Mon Nov 01, 2010 11:49 pm :
Then you'd need exact numbers. I've found random integers isn't as varied as random floats. No clue why.

But the if could be made easier. Two ways:
1)

Code:
if (transmission >= 3) && (transmission < 4)
blah...
if (transmission >=4) && (transmission < 5)


Or

Code:
if (transmission >= 8)
blah...
else if transmission >= 7)
blah..
else....


That (technically) is faster because once it's found what # it is, it exists the if statement & doesn't check the rest.



insanoflex@Posted: Tue Nov 02, 2010 1:05 am :
it was giving me an error when I tried to use &&, thats why I changed it to how it is. Kinda weird I think.

@Sikkpin Fixed, but now I get a '}' is not a type error.

edit: another typo found and fixed and now it works! Maybe I'll try to rewrite it, that could have been the reason I was getting the '&&' is not a type error. Ill post again if doom3 starts hating my script again. Thanks



The Happy Friar@Posted: Tue Nov 02, 2010 3:59 am :
While not required, to me it's just good organization to always put in { & } even if you don't need them.



insanoflex@Posted: Mon Nov 01, 2010 9:40 pm :
Im using a script to trigger radio entities in my map. But when I go to run my map, I am getting some pretty strange compile errors. First, when I used a switch statement for the different radio transmissions, I got an error "Switch is not a type". I changed them to if statements. Started to work, so I changed a few things in it. Now Im getting a "If is not a type" error. Also, am I not allowed to declare int, only float?

code here (sorry kinda messy). The first part is used for some ragdolls.
Code:
/************************************
* Map Scripts for Crewsquarters
***********************************/

//this script launches the two skeletons, revealing some enemies
//location: maintenance access level 1

void ragdollthrow1 ()
{
   $ragdoll1mover.time(.1);
   $ragdoll1mover.moveTo ( $ragdoll1dest );
   $ragdoll2mover.time(.1);
   $ragdoll2mover.moveTo ( $ragdoll2dest );
   sys.waitFor ($ragdoll1mover);
   $ragdoll1.unbind();
   $ragdoll2.unbind();
}

//this script moves the corpse to the pentagram and throws it at
//the ceiling panel, blocking off the room for the fight
//location: breakroom level 1

void ragdollthrow2 ()
{
   //first, bind the corpse to the mover
   sys.trigger ( $ragdollthrow2_soundstinger );
   $ragdoll3.bind( $ragdoll3mover );
   sys.wait(2);

   //move to the pentagram
   sys.trigger ( $ragdollthrow2_soundcrying );
   $ragdoll3mover.time(.5);
   $ragdoll3mover.moveTo( $ragdoll3mover_dest1 );
   sys.waitFor ($ragdoll3mover);
   sys.wait(1);
   $ragdoll3mover.moveTo( $ragdoll3mover_dest2 );
   sys.waitFor ($ragdoll3mover);

        //trigger the pentagram
        sys.trigger( $ragdollthrow2_soundchant );
        sys.trigger( $ragdollthrow2_soundstinger2 );
        sys.wait(1);
   sys.trigger( $ragdollthrow2_pentagram );
   sys.wait(5);
   sys.trigger( $ragdollthrow2_pentagram );

   //move to the ceiling panel
   sys.trigger( $ragdollthrow2_light1 );
        sys.trigger( $ragdollthrow2_light2 );
        sys.trigger( $ragdollthrow2_light3 );
   $ragdoll3mover.moveTo( $ragdoll3mover_dest3 );
   sys.waitFor ($ragdoll3mover);
   $ragdoll3mover.moveTo( $ragdoll3mover_dest4 );
   sys.waitFor ($ragdoll3mover);
   $ragdoll3.unbind();
   sys.trigger( $ragdollthrow2_soundmetal2 );

   //the ceiling panel rotates because of the hit
   $ragdollthrow2_ceilingpanel.time(.4);
   $ragdollthrow2_ceilingpanel.accelTime(.1);
   $ragdollthrow2_ceilingpanel.decelTime(.2);
   $ragdollthrow2_ceilingpanel.rotateOnce( '0 0 90' );
   sys.waitFor( $ragdollthrow2_ceilingpanel );
   sys.trigger( $ragdollthrow2_soundmetal1 );

   //trigger monsters
   sys.trigger( $ragdollthrow2_monstertele );   
}

//This script calls a random radio sound each time it
//is triggered.
//location: whole map

void random_radio ()
{
   float transmission;
   transmission = sys.random(8) + 1;
   sys.print ("triggering radio with value ");
   sys.print (transmission);
   
   if (transmission >= 1)
   {
      if (transmission <= 2)
         sys.trigger($radio_random1);
   }
   if (transmission >= 2)
   {
      if (transmission <= 3)
         sys.trigger($radio_random2);
   }
   if (transmission >= 3)
      if (transmission <= 4)
         sys.trigger($radio_random3);
   }
   if (transmission >= 4)
   {
      if (transmission <= 5)
         sys.trigger($radio_random4);
   }
   if (transmission >= 5)
   {
      if (transmission <= 6)
         sys.trigger($radio_random5);
   }
   if (transmission >= 6)
   {
      if (transmission <= 7)
         sys.trigger($radio_random6);
   }
   if (transmission >= 7)
   {
      if (transmission <= 8)
         sys.trigger($radio_random7);
   }
   if (transmission >= 8)
   {   
      if (transmission <= 9)
         sys.trigger($radio_random8);
   }
}

//This is the radio sound script that calls right after
//the initial invasion.
//location: whole map

void radio_start ()
{
   //We have a codered
   sys.trigger ($radio_codered);
   sys.wait (7);
   
   //Fall back to HQ
   sys.trigger ($radio_fallback);
   sys.wait (10);

   //random radio chatter
   sys.trigger ($radio_someguydying);
   sys.wait (10);

   sys.trigger ($radio_screaming);
   sys.wait (10);

   sys.trigger ($radio_overrun);
   sys.wait (11);
   
   //Say again, fall back to regroup
   sys.trigger ($radio_fallbackrepeat);
   sys.wait (10);

   //calling the random radio script
   float radio_count;
   float max_radio_count;
   radio_count = 0;
   random_radio();
   max_radio_count = sys.random(1)+1;

   while (radio_count < max_radio_count)
   {
      sys.wait (sys.random(4) +20);
      radio_count += 1;
      random_radio();
   }

   //Give sitreps
   sys.trigger ($radio_givesitreps);
   sys.wait (5);
   
   //Sitreps
   sys.trigger ($radio_sitrep1);
   sys.wait (6);
   sys.trigger ($radio_sitrep2);
   sys.wait (14);
   sys.trigger ($radio_sitrep3);
   sys.wait (6);

   //calling the random radio script
   radio_count = 0;
   random_radio ();
   max_radio_count = sys.random(4)+9;
      
   while (radio_count < max_radio_count )
   {
      sys.wait (sys.random(4) +20);
      radio_count += 1;
      random_radio();
   }
}


   
   
}



Sikkpin@Posted: Mon Nov 01, 2010 11:07 pm :
Looks like you are missing the opening bracket here:
Code:
   if (transmission >= 3)
      if (transmission <= 4)
         sys.trigger($radio_random3);
   }

Also, you can cast the random value to an integer like so:
Code:
transmission = int( sys.random(8) + 1 )
This way you only have to do your if's like this:
Code:
if ( transmission == 1 )
    sys.trigger( $radio_random1 );
...etc...



The Happy Friar@Posted: Mon Nov 01, 2010 11:49 pm :
Then you'd need exact numbers. I've found random integers isn't as varied as random floats. No clue why.

But the if could be made easier. Two ways:
1)

Code:
if (transmission >= 3) && (transmission < 4)
blah...
if (transmission >=4) && (transmission < 5)


Or

Code:
if (transmission >= 8)
blah...
else if transmission >= 7)
blah..
else....


That (technically) is faster because once it's found what # it is, it exists the if statement & doesn't check the rest.



insanoflex@Posted: Tue Nov 02, 2010 1:05 am :
it was giving me an error when I tried to use &&, thats why I changed it to how it is. Kinda weird I think.

@Sikkpin Fixed, but now I get a '}' is not a type error.

edit: another typo found and fixed and now it works! Maybe I'll try to rewrite it, that could have been the reason I was getting the '&&' is not a type error. Ill post again if doom3 starts hating my script again. Thanks



The Happy Friar@Posted: Tue Nov 02, 2010 3:59 am :
While not required, to me it's just good organization to always put in { & } even if you don't need them.