level.elepos

Post your scripting questions / solutions here

Moderator: Moderators

Locked
User avatar
PsychoE
Captain
Posts: 243
Joined: Mon Oct 21, 2002 7:40 pm

level.elepos

Post by PsychoE »

I am trying to have 2 elevators in a SP map (One multiple floor and one 2 floor). I am not very good at scripting, so I rely heavily on the tuts and have been using Erick's elevator tut.

I noticed that for both the multiple floor and 2 floor tutorials the scripting shows this:

Code: Select all

level.elepos = x
level waittill spawn

For a second elevator do I use the same "level.elepos = x" twice with different starting positions? How do I differentiate between the 2 elevators?

Also, in the multiple floor script is this line:

Code: Select all

// sets the speed to 64 units per second
  $elevator_cab speed 64
  // starts on floor 1
  level.elepos = 1
  $elevator_cab2 speed 64
What does the $elevator_cab2 speed 64 line mean?
PSYCHO - Who you callin a PSYCHO?

Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Well first you have to realize what a level variable is . It is a variable that can be used in any part of a script and it will always keep it's value . There can be only one in a script if you try to assign a value to it in a different part of the script or even a different script you will change the value of that variable in all the scirpts that are running . So the answer is no you can't use that variable for a second elevator or they will both be using it for the elevator position . You will have to use a different variable for each elevator . If you write the threads right you can use the same threads for each elevator but you have to pass the value to the thread .

Example:
$elevator_cab1 thread moveup
$elevator_cab2 thread moveup

end

moveup:
self moveup 100
end
or
thread moveup $elevator_cab1
thread moveup $elevator_cab2
end

moveup local.e :
local.e moveup 100
end
In the first example the elevator is calling the thread so self is that elevator in the second example you are calling the thread and passing it the elevator you want moved .

The things you put in the game that are models or things like script origins , script models , spawnpoints etc any enity can be give a targetname like $elevator_cab2 when you see the $ in front it is refering to the targetname of an entity .
$elevator_cab2 speed 64
When you use a command like move to move an enity you can set the speed it moves at in game units per second in this case the elevator will move 64 units a second . One word of caution a light entity is not movable so dont' try to move it in script . It is an entity used in the compile so it can't be moved or removed .
Image
User avatar
erick
Major
Posts: 280
Joined: Wed May 30, 2007 1:14 am
Location: USA

Post by erick »

you would have to make 2 level variables if you had to elevators.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

There is no point in having two threads about the same thing Erick and PsychoE use the other thread PsychoE started I am locking this one .
Image
Locked