Jump to content

Script that change saber when you turn off the saber


Recommended Posts

I mean for my flashlight for example. I have two models - flashlight that is flashing and second that is turned off. Turning lightsaber off will change the flashing flashlight to the second model. And it will goes opposite way when we will urn it on.

Link to comment

I tried creating a small test script but it crashes the game whenever I try it.

 

If anyone has a better idea, feel free to contribute:

affect ( "player", FLUSH )
{

	loop ( -1.000 )
	{

		if ( $get( STRING, "SET_SABER1" ) = single_1$ )
		{

			if ( $get( FLOAT, "SET_SABERACTIVE" ) = 0.000$ )
			{
				set ( "SET_SABER1", "single_2" );
			}


			else (  )
			{
				wait ( 1000.000 );
			}

		}


		else (  )
		{

			if ( $get( STRING, "SET_SABER1" ) = single_2$ )
			{

				if ( $get( FLOAT, "SET_SABERACTIVE" ) = 1.000$ )
				{
					set ( "SET_SABER1", "single_1" );
				}


				else (  )
				{
					wait ( 1000.000 );
				}

			}

		}

	}

}


Link to comment

You could take a look at the Alorea mod - spinning the mouse wheel allowed you to change lightsaber entirely. You could probably modify it so that pressing a key or spinning the mouse wheel the flashlight turns on and off. The original KotF also had a submod that allowed you to light up a torch in a similar manner. Not sure if that would work in MP just as well though.

Link to comment

 

I tried creating a small test script but it crashes the game whenever I try it.

 

If anyone has a better idea, feel free to contribute:

affect ( "player", FLUSH )
{

	loop ( -1.000 )
	{

		if ( $get( STRING, "SET_SABER1" ) = single_1$ )
		{

			if ( $get( FLOAT, "SET_SABERACTIVE" ) = 0.000$ )
			{
				set ( "SET_SABER1", "single_2" );
			}


			else (  )
			{
				wait ( 1000.000 );
			}

		}


		else (  )
		{

			if ( $get( STRING, "SET_SABER1" ) = single_2$ )
			{

				if ( $get( FLOAT, "SET_SABERACTIVE" ) = 1.000$ )
				{
					set ( "SET_SABER1", "single_1" );
				}


				else (  )
				{
					wait ( 1000.000 );
				}

			}

		}

	}

}


I think this is a simple issue of a runaway loop. You have a loop value of -1, but there are no wait commands outside the conditional statements. I think this means that the game is performing a near-infinite number of conditional checks every second, thus causing it to crash. 

 

I'd be very interested to hear what happens if you stick in a small wait command, like 50 milliseconds or something, before or after the if/else statement. Everything else about the script seems promising.

Link to comment

I think this is a simple issue of a runaway loop. You have a loop value of -1, but there are no wait commands outside the conditional statements. I think this means that the game is performing a near-infinite number of conditional checks every second, thus causing it to crash. 

 

I'd be very interested to hear what happens if you stick in a small wait command, like 50 milliseconds or something, before or after the if/else statement. Everything else about the script seems promising.

 

You're right. I made a working script, but unfortunately it gets buggy since the lightsaber automatically switches on whenever you change it, so it enters into an infinite loop of turning on and off.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...