Page 1 of 1

script compile error (on elevator)

Posted: February 11th, 2006, 2:02 pm
by The Hughe
Hey

i just started to make maps (4 days ago) and made some work (easy ones without gsc files)
i wanted to created an elevator just into a test map (how it works e.g.) and i have a script compile error

the directory of my files are both in
cod/main/maps/mp (that is probably right)

this is the problem that is been given on my console:
http://rapidshare.de/files/13020777/pic1.GIF.html

This is my GSC file
http://rapidshare.de/files/13020853/ele ... t.gsc.html

And this is my map (bsp and map so you can see how i named my brushes)
http://rapidshare.de/files/13020940/ele ... t.bsp.html
http://rapidshare.de/files/13020982/ele ... t.map.html

it is an very basic map i made (spawn, (simple) skybox, intermission, and elevator .. that is all .. so to find the problem shouldent be that hard i hope some of you guys can help me =)

thnx anyway =)

Posted: February 11th, 2006, 3:21 pm
by Pedsdude

Code: Select all

main() { 
thread elevator_start(); 
} 

elevator_start() { 
elevator = getent ("elevatormodel","targetname"); 
elevator_trig = getent ("elevatorswitch","targetname")

while (1)
{
elevator_trig waittill ("trigger");
wait 3;
elecator movez (956, 3, 1, 2);
elevator waittill ("movedone");
wait 5;
elevator movez (-956, 3, 1, 2);
elevator waittill ("movedone");
wait 1;
}
}
At the end of line 7, you don't have a ;:

Code: Select all

elevator_trig = getent ("elevatorswitch","targetname")
Should be:

Code: Select all

elevator_trig = getent ("elevatorswitch","targetname");
I believe that's the mistake, although if it still doesn't work then let me know and I'll look harder :P

Posted: February 11th, 2006, 3:27 pm
by Luke

Code: Select all

bad token '  ': (File 'maps\mp\elevatortest.gsc'. line 1)
I'm not sure what it is, but thats basically the same script i used in ultra_gap_training, and apart from a typo
elecator movez (956, 3, 1, 2);
and what peds said, apart from that i couldnt find much else :?



Drofder

Posted: February 11th, 2006, 3:28 pm
by Pedsdude
Ah yeah, I didn't see that typo.

Posted: February 11th, 2006, 5:48 pm
by Drofder2004
The only 2 mistakes are spotted.

1 thing, and this wont effect the coding at all, but personally I prefer to put the {} on their own lines (not on the same line as the thread)

So after changing the 2 mistakes above and my own personally preference, this would be the code,

Code: Select all

main() 
{
thread elevator_start();
}

elevator_start() 
{
elevator = getent ("elevatormodel","targetname");
elevator_trig = getent ("elevatorswitch","targetname");

while (1)
{
elevator_trig waittill ("trigger");
wait 3;
elevator movez (956, 3, 1, 2);
elevator waittill ("movedone");
wait 5;
elevator movez (-956, 3, 1, 2);
elevator waittill ("movedone");
wait 1;
}
}
Also your script doesnt work like a real lift, it waits and then automatically comes up. I dont know the proper way of doing this ( I have seen some really fancy ways) but my code would be [untested]

Code: Select all

main() 
{
thread elevator_start();
}

elevator_start() 
{
elevator = getent ("elevatormodel","targetname");
elevator_trig = getent ("elevatorswitch","targetname");
position = 0;

while (1)
{
elevator_trig waittill ("trigger");
wait 3;
if(position == 0)
{
elevator movez (956, 3, 1, 2);
position = 1;
}
else if(position == 1)
{
elevator movez (-956, 3, 1, 2);
position = 0;
}
elevator waittill ("movedone");
}
}
Also, another thing I would do is use moveto instead of movez. This is simply to stop problems of the lift not going back to the exact position if it gets stuck.

As I said the code is untested but it looks fine ;)

Posted: February 11th, 2006, 5:54 pm
by Pwn-Rikku
lol drofders here before me.

Posted: February 11th, 2006, 6:44 pm
by The Hughe
@Pedsdude thnx .. i will look for that kind of mistakes more often if it will give that kind of error =)

@Luke you are right .. it is the same script cos i was trying to make one myself but i didnt get it working so i kinda copie it and try if it was working :wink: i hope you dont mind :roll: only because of my lazyness to modifie the heights and speed

@drofder2004 Thnx ... your script worked very good .. :D

@Pwn-Rikku .. no comment :P

Posted: February 11th, 2006, 6:56 pm
by Luke
I don't care if u use a script i've used, i got it from some other map anyway...just odd i couldnt get it to work on your map but it worked first time on mine.

Posted: February 11th, 2006, 8:35 pm
by Pedsdude
Could you give an example for moveto Drofder?

Posted: February 11th, 2006, 9:33 pm
by Luke
KillerSam wrote:thats what i was wondering....is it just replace movey with moveto and then the co-ordinates instead of the amount?
yeah..i've been trying to make a realistic elevator coz rince asked me to, but i've been using movez for the up and down movement, and moveto for the doors, this is what i used for the doors, using a trigger_multiple so theyre like realistic automatic doors:

Code: Select all

door2()
{
door3 = getent ("door3","targetname");
door4 = getent ("door4","targetname");
door_trig2 = getent ("door_trig2","targetname");

while (1)
{
door_trig2 waittill ("trigger");
door3 moveto ((0, 32,0), 1,0.5,0.5);
door4 moveto ((0, -32,0), 1,0.5,0.5);
wait (1);
door3 moveto ((0, 0,0), 1,0.5,0.5);
door4 moveto ((0, 0,0),  1,0.5,0.5);
}
}
That seems to work well for what I wanted, but this is what i used for 1 of my elevators:


Code: Select all

elevator1()
{
door1 = getent ("door1","targetname");
door2 = getent ("door2","targetname");
door1_button = getent ("door1_button","targetname");
door1a = getent ("door1a","targetname");
door1b = getent ("door1b","targetname");
lift1 = getent ("lift1","targetname");
lift1_trig = getent ("lift1_trig","targetname");
lift1_sound = getent ("lift1_sound","targetname");

while (1)
{
lift1_trig waittill ("trigger",user);
door1a moveto ((0, -32,0), 1,0.5,0.5);
door1b moveto ((0, 32,0), 1,0.5,0.5); 
wait (3);
lift1_sound playsound("lift1");
lift1 movez (511, 3, 1, 2);
door1a movez (511, 3, 1, 2);
door1b movez (511, 3, 1, 2);
door1_button movez (511, 3, 1, 2);
wait 3;
door1a movey (32, 3, 1, 2);
door1b movey (-32, 3, 1, 2);
wait 6;
door1a movey (-32, 3, 1, 2);
door1b movey (32, 3, 1, 2);
wait 3;
lift1_sound playsound("lift1");
lift1 movez (-511, 3, 1, 2);
door1a movez (-511, 3, 1, 2);
door1b movez (-511, 3, 1, 2);
door1_button movez (-511, 3, 1, 2);
lift1 waittill ("movedone");
wait 1;
door1a moveto ((0, 0,0), 1,0.5,0.5);
door1b moveto ((0, 0,0), 1,0.5,0.5);
door1 moveto ((0, 32,0), 1,0.5,0.5);
door2 moveto ((0, -32,0), 1,0.5,0.5);
}
}

I cba to change it all, even if they do get stuck lol...i used movey for the doors that go up with the elevator, coz i needed the doors to close at the top, and if i used moveto the doors would go back to their origin first and close :s

Posted: February 11th, 2006, 11:26 pm
by Drofder2004
The moveto function works exactly how it says it does, it moves the script_whatever to an origin.

So, you make your script_brushmodel (either make sure it has an origin brush or an origin key)

The functions works like this

variable moveto ((x,y,z),t,a,d)
(x,y,z) = the exact coordinates
t = time it should take
a = acceleraion
d = decceleration

(a+d) =< t

Use the editor to get origins of all the positions.

Posted: February 11th, 2006, 11:30 pm
by Pedsdude
Ah i see. I haven't used origins before, so might give it a go in the near future.

Posted: February 12th, 2006, 12:20 am
by Luke
I don't see much difference tbh, except the moveto function has a fixed origin, so when u tell it to move something it will always move from its origin first, thats what i've found with it anyway. so i assume with that theres no way to (for example) make something moveto up 100 units, wait, and move from that spot to another?

Posted: February 12th, 2006, 11:20 am
by Drofder2004
Luke wrote:I don't see much difference tbh, except the moveto function has a fixed origin, so when u tell it to move something it will always move from its origin first, thats what i've found with it anyway. so i assume with that theres no way to (for example) make something moveto up 100 units, wait, and move from that spot to another?
movez (100, 1)
wait 3;
move...

???

Moveto is the best option because movex/y/z can screw up and move to far. e.g

Lift at z of 0
moves up to 100
tries to move down to 0 again but is blocked (script gets confused)
lift then moves up again to 200. (lift is now flying above the building :P)

Posted: February 12th, 2006, 1:38 pm
by Luke
ok, don't think i've seen that happen yet, but i'll try that