Page 1 of 1

simple crane move

Posted: Fri Nov 14, 2003 8:53 pm
by Machu
Ok, I am a complete noob at scripting :oops: ...so I need you guy's help. I've been playing around/experimenting a lot and am currently trying to make a little crane that can move back and forth along a track on the ceiling. I've made a trigger_use for a button and gave it a targetname of "crane_button" And, for now, I have a one piece crane made out of a script object with the targetname of "crane". I made two waypoints with targetnames of "waypoint_near" and "waypoint_far". All I want it to do for now is to move to one end of the track when you push the button, then move back after 3 sec.

here is the thread I tried:

crane_mover:

$crane moveto $waypoint_near
$crane_button waittill trigger
$crane moveto $waypoint_far
wait 3
$crane moveto $waypoint_near

goto crane_mover

end

I know this is very simple and I probly did something very stupid, but it would really help if someone could explain what I need to do.

ty peeple

Posted: Fri Nov 14, 2003 9:51 pm
by bdbodger
whenever you use a movement command like moveto or moveup etc you need to use the move or waitmove command after it . You can use several movement commands before the move command . You also need a speed setting for movement commands or a time setting for rotation commands .

This example will move the crane up 20 and left 10 at a speed of 5 .


$crane speed 5 // 5 units per second
$crane moveup 20
$crane moveleft 10
$crane move // or $crane waitmove

This example will also move up 20 and left 10 but it will do one then the other not both at once

$crane speed 5 // 5 units per second
$crane moveup 20
$crane waithmove
$crane moveleft 10
$crane move // or $crane waitmove

The difference between move and waitmove is that with waitmove the script will wait untill movement is done before continueing .

waypoints

Posted: Sat Nov 15, 2003 2:07 am
by tltrude
You don't really have to use waypoints because you can make it move in a direction too.

$crane time 5 // travel time in seconds
$crane moveEast 1024
$crane move

Posted: Sat Nov 15, 2003 1:22 pm
by Machu
Thanks guys. That solved a lot of problems for me :D

Posted: Sun Nov 16, 2003 3:43 am
by nuggets
while the crane is moving back to it's original position, the button will still be triggerable, making it possible to send it to the waypoint_far again, if this is what you need, then stick with waypoints,

using both bdbodger's and tltrude's methods will have an advantage as to not using waypoints, but if the trigger is pressed while it's moving it'll move again and probably end up off the rails you've created, or even move through a wall... :(

an easy way to overcome this...

crane_mover:

$crane_button nottriggerable //turns the trigger off
$crane speed 5 //will move 5 units per second or use $crane time 5 will take 5 seconds to reach it's destination
$crane moveEast 1024
$crane waitmove
wait 3
$crane moveWest 1024
$crane waitmove
$crane_button triggerable //turns it back on

end

with movement commands you can use any of these...
moveNorth
moveSouth
moveWest
moveEast
moveLeft
moveRight
moveForward
moveBackward
moveUp
moveDown
each with the prefix of the entity name in you case $crane and the suffix number of units

also when you have a certain position you want to move it to you can use
moveTo
where it moves to another entity or point on the map
$crane moveTo $player

if you want to you can rotate entities aswell (bear in mind though not models),
rotateXup
rotateXdown
rotateYup
rotateYdown
rotateZup
rotateZdown
all of these again will have the prefix of entity and suffix this time of the angle
$crane rotateXup 45
also note that when using rotate, you will need to use time and not speed, as the number of units moved is 0

anyway back to the point...

if you wanted the crane moveabe at all times where it'll move to it's waypoint_far all the time (in these examples you don't need any waypoints), what i'd do...

main:
$crane.newposition = ($crane.origin + (0 1240 0))
$crane.oldposition = $crane.origin
$crane speed 5
end

crane_mover:
$crane moveto $crane.newposition
$crane waitmove
wait 3
$crane moveto $crane.oldposition
$crane waitmove
end

when using something that always triggerable, use speed, as time will speed up if it's already on it's way to the destination

in the above example i've set some constants that'll never change,
$crane.newposition and .oldposition, these are just names i've made up but .origin is a variable that is determined by where the $crane is

constants = values that will never change
variables = values that can change
there's no real need to know the difference between constants and variables, just thought i'd throw that one in there

for now u've got enough to get your head around so, good luck :D