Page 1 of 1

compil script errror with my map

Posted: June 21st, 2009, 4:18 pm
by soyeur
hi all im making aa fun map wiith elevator and teleporter and when i finished my map there where a script error and when i deleted my elevator with her script the map works and the teleporter too and wheen i deletaed my teleporter my elevator worked so i think there is a syntax error in my map.gsc so can you say me what's wrong !


my gsc file:

main() {
level.elevatorDown = true; // elevator starts at bottom: true/false
level.elevatorMoving = false; // elevator is not currently moving
thread elevator_start();
}

elevator_start() {
elevator = getentarray ("elevatorswitch","targetname");
if ( isdefined(elevator) )
for (i = 0; i < elevator.size; i++)
elevator thread elevator_think();
}

elevator_think() {
while (1) {
self waittill ("trigger");
if (!level.elevatorMoving)
thread elevator_move();
}
}

elevator_move() {
elevatormodel = getent ("elevatormodel", "targetname");
level.elevatorMoving = true;
speed = 2;
height = 228;
wait (1);
if (level.elevatorDown) { // moves to top
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height, speed);
elevatormodel waittill ("movedone");
level.elevatorDown = false;
}
else { // moves to bottom
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height - (height * 2), speed);
elevatormodel waittill ("movedone");
level.elevatorDown = true;
}
level.elevatorMoving = false;
}
{
thread teleporter();
}
teleporter()
{
trigger = getent ("teleporter", "targetname");
while(1)
{
trigger waittill ("trigger",user);
user iprintlnbold ("Now Teleporting...");
wait(1);
user setOrigin( (816 , -1016, 432) );
wait(1);
}
}

Re: compil script errror with my map

Posted: June 21st, 2009, 5:51 pm
by Drofder2004
As long as there is only 1 line after and if or for statement it is fine...

ie..

if(a == 1)
runThread();

but doing something like

if(a == 1)
sayHello();
runthread();

If 'a' is not equal to 1, it will still run anything after the first line (runthread)...

I will look after eating my steak :P

Re: compil script errror with my map

Posted: June 21st, 2009, 11:57 pm
by Drofder2004
Ok, here is the code in its NORMAL format, none of that 'brakets-on-same-line' shit. If you are going to open up curly brackets, move then to the line below >.<

Code: Select all

main() 
{
	level.elevatorDown = true; // elevator starts at bottom: true/false
	level.elevatorMoving = false; // elevator is not currently moving
	thread elevator_start();
}

elevator_start() 
{
	elevator = getentarray ("elevatorswitch","targetname");
	if ( isdefined(elevator) )
		for (i = 0; i < elevator.size; i++)
			elevator[i] thread elevator_think();
}

elevator_think()
{
	while (1) 
	{
		self waittill ("trigger");
		if (!level.elevatorMoving)
			thread elevator_move();
	}
}

elevator_move()
{
	elevatormodel = getent ("elevatormodel", "targetname");
	level.elevatorMoving = true;
	speed = 2;
	height = 228;
	wait (1);
	if (level.elevatorDown) 
	{ // moves to top
		elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
			
		wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
		elevatormodel moveZ (height, speed);
		elevatormodel waittill ("movedone");
		level.elevatorDown = false;
	}
	else
	{ // moves to bottom
		elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
		wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
		elevatormodel moveZ (height - (height * 2), speed);
		elevatormodel waittill ("movedone");
		level.elevatorDown = true;
	}
	level.elevatorMoving = false;
}

{
thread teleporter();
}

teleporter()
{
	trigger = getent ("teleporter", "targetname");
	while(1)
	{
		trigger waittill ("trigger",user);
		user iprintlnbold ("Now Teleporting...");
		wait(1);
		user setOrigin( (816 , -1016, 432) );
		wait(1);
	}
}
For some unknown reason, you will see the following just floating outside of a function...

Code: Select all

{
thread teleporter();
}
That needs to be put in the main functions, without using the brackets...

And yes, it was £5 worth of fucking big, thick irish beef rump steak, cooked well done, but I had errands to run and then gaming to do first.

Re: compil script errror with my map

Posted: June 22nd, 2009, 12:49 am
by soyeur
tthat doesnt works =( but when i delete my elevator my teleporter works and when i delete my teleporter my elevator works

Re: compil script errror with my map

Posted: June 22nd, 2009, 1:02 am
by Pedsdude
What about this?

Code: Select all

main() 
{
	level.elevatorDown = true; // elevator starts at bottom: true/false
	level.elevatorMoving = false; // elevator is not currently moving
	thread elevator_start();
	thread teleporter();
}

elevator_start() 
{
	elevator = getentarray ("elevatorswitch","targetname");
	if ( isdefined(elevator) )
		for (i = 0; i < elevator.size; i++)
			elevator[i] thread elevator_think();
}

elevator_think()
{
	while (1) 
	{
		self waittill ("trigger");
		if (!level.elevatorMoving)
			thread elevator_move();
	}
}

elevator_move()
{
	elevatormodel = getent ("elevatormodel", "targetname");
	level.elevatorMoving = true;
	speed = 2;
	height = 228;
	wait (1);
	if (level.elevatorDown) 
	{ // moves to top
		elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
			
		wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
		elevatormodel moveZ (height, speed);
		elevatormodel waittill ("movedone");
		level.elevatorDown = false;
	}
	else
	{ // moves to bottom
		elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
		wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
		elevatormodel moveZ (height - (height * 2), speed);
		elevatormodel waittill ("movedone");
		level.elevatorDown = true;
	}
	level.elevatorMoving = false;
}

teleporter()
{
	trigger = getent ("teleporter", "targetname");
	while(1)
	{
		trigger waittill ("trigger",user);
		user iprintlnbold ("Now Teleporting...");
		wait(1);
		user setOrigin( (816 , -1016, 432) );
		wait(1);
	}
}

Re: compil script errror with my map

Posted: June 22nd, 2009, 1:08 am
by soyeur
that's working thnaks you alot but if i want to make more teleporters and elevator? how ca n i do?

Re: compil script errror with my map

Posted: June 22nd, 2009, 1:22 am
by soyeur
ok ty alot mate !

Re: compil script errror with my map

Posted: June 22nd, 2009, 1:37 am
by soyeur
hum i made a second teleporter but that's not working =( look at my gsc file:


main()
{
level.elevatorDown = true; // elevator starts at bottom: true/false
level.elevatorMoving = false; // elevator is not currently moving
thread elevator_start();
thread teleporter();
thread teleporter1();
}

elevator_start()
{
elevator = getentarray ("elevatorswitch","targetname");
if ( isdefined(elevator) )
for (i = 0; i < elevator.size; i++)
elevator thread elevator_think();
}

elevator_think()
{
while (1)
{
self waittill ("trigger");
if (!level.elevatorMoving)
thread elevator_move();
}
}

elevator_move()
{
elevatormodel = getent ("elevatormodel", "targetname");
level.elevatorMoving = true;
speed = 2;
height = 228;
wait (1);
if (level.elevatorDown)
{ // moves to top
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv

wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height, speed);
elevatormodel waittill ("movedone");
level.elevatorDown = false;
}
else
{ // moves to bottom
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height - (height * 2), speed);
elevatormodel waittill ("movedone");
level.elevatorDown = true;
}
level.elevatorMoving = false;
}

teleporter()
{
trigger = getent ("teleporter", "targetname");
while(1)
{
trigger waittill ("trigger",user);
user iprintlnbold ("Now Teleporting...");
wait(1);
user setOrigin( (1375 , 1016, -293) );
wait(1);
}
}
main()
{
level.elevatorDown = true; // elevator starts at bottom: true/false
level.elevatorMoving = false; // elevator is not currently moving
thread elevator_start();
thread teleporter();
}

elevator_start()
{
elevator = getentarray ("elevatorswitch","targetname");
if ( isdefined(elevator) )
for (i = 0; i < elevator.size; i++)
elevator thread elevator_think();
}

elevator_think()
{
while (1)
{
self waittill ("trigger");
if (!level.elevatorMoving)
thread elevator_move();
}
}

elevator_move()
{
elevatormodel = getent ("elevatormodel", "targetname");
level.elevatorMoving = true;
speed = 2;
height = 228;
wait (1);
if (level.elevatorDown)
{ // moves to top
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv

wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height, speed);
elevatormodel waittill ("movedone");
level.elevatorDown = false;
}
else
{ // moves to bottom
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height - (height * 2), speed);
elevatormodel waittill ("movedone");
level.elevatorDown = true;
}
level.elevatorMoving = false;

teleporter1()
{
trigger = getent ("teleporter1", "targetname");
while(1)
{
trigger waittill ("trigger",user);
user iprintlnbold ("Now Teleporting...");
wait(1);
user setOrigin( (1300 , 9777, -293) );
wait(1);

Re: compil script errror with my map

Posted: June 22nd, 2009, 1:48 am
by Pedsdude
Eugh, there's no need to copy/paste all of the previous code for the new teleporter to work.

Here's a fixed version:

Code: Select all

main() 
{
	level.elevatorDown = true; // elevator starts at bottom: true/false
	level.elevatorMoving = false; // elevator is not currently moving
	thread elevator_start();
	thread teleporter();
	thread teleporter1();
}

elevator_start() 
{
	elevator = getentarray ("elevatorswitch","targetname");
	if ( isdefined(elevator) )
		for (i = 0; i < elevator.size; i++)
			elevator[i] thread elevator_think();
}

elevator_think()
{
	while (1) 
	{
		self waittill ("trigger");
		if (!level.elevatorMoving)
			thread elevator_move();
	}
}

elevator_move()
{
	elevatormodel = getent ("elevatormodel", "targetname");
	level.elevatorMoving = true;
	speed = 2;
	height = 228;
	wait (1);
	if (level.elevatorDown) 
	{ // moves to top
		elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
			
		wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
		elevatormodel moveZ (height, speed);
		elevatormodel waittill ("movedone");
		level.elevatorDown = false;
	}
	else
	{ // moves to bottom
		elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
		wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
		elevatormodel moveZ (height - (height * 2), speed);
		elevatormodel waittill ("movedone");
		level.elevatorDown = true;
	}
	level.elevatorMoving = false;
}

teleporter()
{
	trigger = getent ("teleporter", "targetname");
	while(1)
	{
		trigger waittill ("trigger",user);
		user iprintlnbold ("Now Teleporting...");
		wait(1);
		user setOrigin( (816 , -1016, 432) );
		wait(1);
	}
}

teleporter1()
{
	trigger = getent ("teleporter1", "targetname");
	while(1)
	{
		trigger waittill ("trigger",user);
		user iprintlnbold ("Now Teleporting...");
		wait(1);
		user setOrigin( (1300 , 9777, -293) );
		wait(1);
	}
}
Of course, made sure that in the map editor you copied the older trigger and renamed the targetname to "teleporter1".

Re: compil script errror with my map

Posted: June 22nd, 2009, 1:53 am
by soyeur
ty

Re: compil script errror with my map

Posted: June 22nd, 2009, 2:41 am
by Nightmare
Jesus christ, please, please, please, please DO NOT use that useless script at modsonline.
It is terribly inefficient and confusing.

Code: Select all

main() 
{
	moveElevator();
	thread teleporter();
	thread teleporter1();
}

moveElevator()
{
	while(1)
	{
		trigger = getent ("elevatorTrigger","targetname");	//Assign trigger entitiy to variable trigger
		ele = getent ("elevatorModel", "targetname");		//Assign elevator entity to variable ele
		trigger waittill ("trigger");				//Wait till triggered
		ele moveZ (228, 2);					//Move elevator along Z axis 228 units (Up) in 2 seconds
		ele waittill ("movedone");				//Wait until elevator entity has finished moving
		wait 5;							//Wait 5 seconds
		ele moveZ (-228, 2);					//Move elevator along Z axis -228 units (Down) in 2 seconds
		ele waittill ("movedone");				
		wait 0.05;
	}
}

teleporter()
{
	trigger = getent ("teleporter", "targetname");
	while(1)
	{
		trigger waittill ("trigger",user);
		user setOrigin( (816 , -1016, 432) );
		wait(1);
	}
}

teleporter1()
{
	trigger = getent ("teleporter1", "targetname");
	while(1)
	{
		trigger waittill ("trigger",user);
		user setOrigin( (1300 , 9777, -293) );
		wait(1);
	}
}
Also, I cannot stress this enough, but please use your map name in front for the targetname if possible.
For example: mapname_elevatorTrigger.
This helps prevent conflicting with other maps.

If you still don't fully follow on how to make moving script_brushmodels, follow my tutorial here: viewtopic.php?f=18&t=2963.
I promise it will make much more sense than what is posted at ModsOnline.

Re: compil script errror with my map

Posted: June 22nd, 2009, 5:01 am
by Drofder2004
Nightmare wrote:Jesus christ, please, please, please, please DO NOT use that useless script at modsonline.
It is terribly inefficient and confusing.
lol, was gonna say the same, but didn't want to get too involved. Fix it and get out :P

Re: compil script errror with my map

Posted: June 22nd, 2009, 3:26 pm
by soyeur
i would like to know how to put health pack and weapons (bar,mp44...) on my map please

Re: compil script errror with my map

Posted: June 22nd, 2009, 4:59 pm
by Drofder2004
In radiant, right click the 2D window, I think they are under "mp" or somewhere in that drop down list.