Page 1 of 1

Code Problem

Posted: July 20th, 2009, 11:12 pm
by CONKER
I'm trying to make a handle rotate, but for some reason it shows the hand symbol for you to press F but when I press F it doesn't do anything. Here's my code.

Code: Select all

main()

{

thread handle();


}

handle()

{

handle = getent ("Handle","targetname");

trig = getent ("Handle_Trigger","targetname");

while(1)

{

trig waittill ("Trigger");

handle rotateroll (-1080,5);

wait(10);

handle rotateroll(1080,5);

handle waittill ("movedone");

}

}
Does anyone know whats wrong with my code?

Re: Code Problem

Posted: July 20th, 2009, 11:16 pm
by Nightmare
CONKER wrote:I'm trying to make a handle rotate, but for some reason it shows the hand symbol for you to press F but when I press F it doesn't do anything. Here's my code.
Does anyone know whats wrong with my code?

Code: Select all

main()
{
	thread handle();
}

handle()
{
	handle = getent("Handle","targetname");
	trig = getent("Handle_Trigger","targetname");
	while(1)
	{
		trig waittill("trigger");
		handle rotateroll (-1080,5);
		handle waittill("rotatedone");
		wait(10);
		handle rotateroll(1080,5);
		handle waittill("rotatedone");
	}
}
Make sure when you created your handle that you added an origin brush for the rotation axis,
Make sure you use rotatedone instead of movedone when dealing with a rotation.
Also, double check the targetnames, they might not match.

Lastly, please put your map name in front of the targetnames to avoid conflicting with other maps.

Re: Code Problem

Posted: July 20th, 2009, 11:30 pm
by CONKER
Well anyway I got it to work, thanks for the help guys.

Re: Code Problem

Posted: July 20th, 2009, 11:53 pm
by CONKER
Sorry for double post, but I'm having another problem with my code cuz im trying to make it were when you use the same trigger it will move one part of a door up and the other down here is my code.

Code: Select all

doordownthread()

{

doordownobject = getent ("door_down","targetname");

trig = getent ("Handle_Trigger","targetname");

while(1)

{

trig waittill ("trigger");

doordownobject movez (-56,5);

wait(10);

doordownobject movez (56,5);

doordownobject waittill ("movedone");

}

}

doorupthread()

{

doorupobject = getent ("door_up","targetname");

trig = getent ("Handle_Trigger","targetname");

while(1)

{

trig waittill ("trigger");

doorupobject movez (56,5);

wait(10);

doorupobject movez (-56,5);

doorupobject waittill ("movedone");

}

}
why isn't it working?

Re: Code Problem

Posted: July 21st, 2009, 12:03 am
by Nightmare
What does your main thread look like?

Re: Code Problem

Posted: July 21st, 2009, 12:20 am
by CONKER
Nightmare wrote:What does your main thread look like?

Code: Select all

main()

{

thread handlethread();
thread doordownthread();
thread doorupthread();

}

Re: Code Problem

Posted: July 21st, 2009, 12:58 am
by Nightmare
Try this on for size.
Also, as I said before, please change those targetnames.

Code: Select all

main()
{
	thread doorMovement();
}

doorMovement()
{
	up = getent ("door_up","targetname");
	down = getent ("door_down","targetname");
	trig = getent ("Handle_Trigger","targetname");
	while(1)
	{
		trig waittill ("trigger");
		up movez(56,5);
		down movez(-56,5);
		up waittill ("movedone");
		wait(10);
		up movez(-56,5);
		down movez(56,5);
		up waittill ("movedone");
	}
}

Re: Code Problem

Posted: July 21st, 2009, 1:02 am
by Pedsdude
I just spent 5-10 mins typing a response and when I clicked submit Nightmare had already done exactly what I typed (except for targetname changes)!

It's also worth perhaps using targetnames which are exclusive to your map to avoid conflicts, e.g. conkers_map_up, conkers_map_down, conkers_map_handle_trigger etc. (although the latter one, 'Handle_Trigger' almost certainly won't conflict with any current maps.

It's not a neccessity but it has been brought up in the past.