Ryan

Scripting Help

7 posts in this topic

Hello RAID, so I'm here to ask some help on this script. The way I have it set up is that when it's activated it will go through and pick one of the choices randomly and it works fine but what I need help with is that I want to get the brush rotations to be constant and not stop. I tried adding while(1) in different places but that didn't work out. I'm still pretty new to scripting so I'm not sure if I'm just missing something or I didn't set it up the right way for what I want it to do, anyways, any help would be appreciated! Thanks ;)

 

Here's the script: 

trap9()
{
	brush1 = getEnt("trap9","targetname");
	brush2 = getEnt("trap9.1","targetname");
	brush3 = getEnt("trap9.2","targetname");
	trigger = getEnt("trap9_trig","targetname");
	trigger waittill("trigger");
	
		x = randomInt(3);
		
		if (x == 1)
		{	
			brush1 rotateRoll(360,2);
			brush2 rotateRoll(360,2);
			brush3 rotateRoll(360,2);
			brush2 notsolid();
			brush3 notsolid();
		}
		if (x == 2)
		{
			brush1 rotateRoll(360,2);
			brush2 rotateRoll(360,2);
			brush3 rotateRoll(360,2);
			brush1 notsolid();
			brush3 notsolid();
		}
		if (x == 3)
		{
			brush1 rotateRoll(360,2);
			brush2 rotateRoll(360,2);
			brush3 rotateRoll(360,2);
			brush1 notsolid();
			brush2 notsolid();
		}
		
	trigger delete();
}
0

Share this post


Link to post
Share on other sites

 

Hello RAID, so I'm here to ask some help on this script. The way I have it set up is that when it's activated it will go through and pick one of the choices randomly and it works fine but what I need help with is that I want to get the brush rotations to be constant and not stop. I tried adding while(1) in different places but that didn't work out. I'm still pretty new to scripting so I'm not sure if I'm just missing something or I didn't set it up the right way for what I want it to do, anyways, any help would be appreciated! Thanks ;)

 

Here's the script: 

trap9()
{
	brush1 = getEnt("trap9","targetname");
	brush2 = getEnt("trap9.1","targetname");
	brush3 = getEnt("trap9.2","targetname");
	trigger = getEnt("trap9_trig","targetname");
	
        trigger waittill("trigger");
        trigger delete();
	
		x = randomInt(3);
		
		if (x == 0)
		{
                   brush2 notsolid();
                   brush3 notsolid();	

                   while(1) {
			brush1 rotateRoll(360,2);
			brush2 rotateRoll(360,2);
			brush3 rotateRoll(360,2);
                        brush3 waittill("rotatedone");
                   }
		}
		else if (x == 1)
		{
                   brush1 notsolid();
                   brush3 notsolid();

                   while(1) {
			brush1 rotateRoll(360,2);
			brush2 rotateRoll(360,2);
			brush3 rotateRoll(360,2);
                        brush3 waittill("rotatedone");
                  }
		}
		else if (x == 2)
		{
                    brush1 notsolid();
                    brush2 notsolid();

                    while(1) {
			brush1 rotateRoll(360,2);
			brush2 rotateRoll(360,2);
			brush3 rotateRoll(360,2);
                        brush3 waittill("rotatedone");
                   }
		}
		
}

 

Did you meant it like this? So that it chooses a random number and then loop the one that matches?

0

Share this post


Link to post
Share on other sites

Yes I did, but I actually tried it like that but when the trap was activated it would freeze the game for a bit and if I remember correctly it still didn't work.

0

Share this post


Link to post
Share on other sites


trap9()
{
    brush1 = getEnt("trap9","targetname");
    brush2 = getEnt("trap9.1","targetname");
    brush3 = getEnt("trap9.2","targetname");
    trigger = getEnt("trap9_trig","targetname");
    trigger waittill("trigger");
    
    x = randomInt(3);
        
    if (x == 1)
    {    
        brush1 thread rotate();
        brush2 thread rotate();
        brush3 thread rotate();
        brush2 notsolid();
        brush3 notsolid();
    }
    if (x == 2)
    {
        brush1 thread rotate();
        brush2 thread rotate();
        brush3 thread rotate();
        brush1 notsolid();
        brush3 notsolid();
    }
    if (x == 3)
    {
        brush1 thread rotate();
        brush2 thread rotate();
        brush3 thread rotate();
        brush1 notsolid();
        brush2 notsolid();
    }
        
    trigger delete();
}
 
rotate()
{
while( 1 )
{
self rotateRoll( 360, 2 );
//self waittill( "movedone" ); //hummm, no ... unless it's rotatedone? dunno.
wait( 2 );
}
}

0

Share this post


Link to post
Share on other sites

 

trap9()
{
    brush1 = getEnt("trap9","targetname");
    brush2 = getEnt("trap9.1","targetname");
    brush3 = getEnt("trap9.2","targetname");
    trigger = getEnt("trap9_trig","targetname");
    trigger waittill("trigger");
    
    x = randomInt(3);
        
    if (x == 1)
    {    
        brush1 thread rotate();
        brush2 thread rotate();
        brush3 thread rotate();
        brush2 notsolid();
        brush3 notsolid();
    }
    if (x == 2)
    {
        brush1 thread rotate();
        brush2 thread rotate();
        brush3 thread rotate();
        brush1 notsolid();
        brush3 notsolid();
    }
    if (x == 3)
    {
        brush1 thread rotate();
        brush2 thread rotate();
        brush3 thread rotate();
        brush1 notsolid();
        brush2 notsolid();
    }
        
    trigger delete();
}
 
rotate()
{
    while( 1 )
    {
        self rotateRoll( 360, 2 );
        //self waittill( "movedone" ); //hummm, no ... unless it's rotatedone? dunno.
        wait( 2 );
    }
}

 

 

 

yes it's rotatedone

0

Share this post


Link to post
Share on other sites

Thanks for the help Bear, but unfortunately it didn't work. The brushes wouldn't rotate at all or become not solid. 

 

Edit: I'm stupid, I forgot to rethread the trap :facepalm: Works, thanks alot :)

0

Share this post


Link to post
Share on other sites

Thanks for the help Bear, but unfortunately it didn't work. The brushes wouldn't rotate at all or become not solid. 

 

Edit: I'm stupid, I forgot to rethread the trap :facepalm: Works, thanks alot :)

Ah i was thinking in my head if you even done that. should of said something earlier

0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now