47 lines
No EOL
1.3 KiB
JavaScript
47 lines
No EOL
1.3 KiB
JavaScript
/* globals Script Entities Vec3 */
|
|
|
|
(function() {
|
|
|
|
var goingUp = true;
|
|
|
|
var pointA = {x: -17.8275, y: -9.9549, z: 3.7508};
|
|
var pointB = {x: -17.8275, y: 109.1, z: 3.7508};
|
|
|
|
var pauseTime_ground = 10; // seconds
|
|
var pauseTime_top = 27;
|
|
var MOVE_TIME_UP = 20;
|
|
var DROP_TIME = 3;
|
|
|
|
var _entityID;
|
|
this.preload = function(entityID) {
|
|
_entityID = entityID;
|
|
Script.setInterval(function() {
|
|
movePlatform(goingUp);
|
|
goingUp = !goingUp;
|
|
}, (pauseTime_ground + MOVE_TIME_UP) * 1000);
|
|
};
|
|
|
|
var movePlatform = function(isGoingUp) {
|
|
var from = isGoingUp ? pointA : pointB;
|
|
var to = isGoingUp ? pointB : pointA;
|
|
var moveTime = isGoingUp ? MOVE_TIME_UP : DROP_TIME;
|
|
|
|
var moveDirection = Vec3.subtract(to , from);
|
|
var moveVelocity = Vec3.multiply(moveDirection, 1 / moveTime);
|
|
|
|
Entities.editEntity(_entityID, {
|
|
velocity: moveVelocity,
|
|
position: from,
|
|
damping: 0
|
|
});
|
|
|
|
Script.setTimeout(function() {
|
|
Entities.editEntity(_entityID, {
|
|
velocity: {x: 0, y: 0, z: 0},
|
|
position: to
|
|
});
|
|
}, moveTime * 1000);
|
|
|
|
};
|
|
|
|
}); |