Code Problem

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
User avatar
CONKER
CJ Wannabe
CJ Wannabe
Posts: 13
Joined: June 30th, 2009, 2:25 am

Code Problem

Post by CONKER » July 20th, 2009, 11:12 pm

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?

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Code Problem

Post by Nightmare » July 20th, 2009, 11:16 pm

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.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
CONKER
CJ Wannabe
CJ Wannabe
Posts: 13
Joined: June 30th, 2009, 2:25 am

Re: Code Problem

Post by CONKER » July 20th, 2009, 11:30 pm

Well anyway I got it to work, thanks for the help guys.

User avatar
CONKER
CJ Wannabe
CJ Wannabe
Posts: 13
Joined: June 30th, 2009, 2:25 am

Re: Code Problem

Post by CONKER » July 20th, 2009, 11:53 pm

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?

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Code Problem

Post by Nightmare » July 21st, 2009, 12:03 am

What does your main thread look like?
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
CONKER
CJ Wannabe
CJ Wannabe
Posts: 13
Joined: June 30th, 2009, 2:25 am

Re: Code Problem

Post by CONKER » July 21st, 2009, 12:20 am

Nightmare wrote:What does your main thread look like?

Code: Select all

main()

{

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

}

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Code Problem

Post by Nightmare » July 21st, 2009, 12:58 am

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");
	}
}
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Code Problem

Post by Pedsdude » July 21st, 2009, 1:02 am

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.
Image
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests