2019-04-19 01:15:05 +00:00
|
|
|
function main() {
|
2020-04-22 06:50:45 +00:00
|
|
|
console.log("%s initialized!", Self.Title);
|
2019-04-19 01:15:05 +00:00
|
|
|
|
2019-05-07 05:57:32 +00:00
|
|
|
Self.AddAnimation("open", 100, [0, 1, 2, 3]);
|
|
|
|
Self.AddAnimation("close", 100, [3, 2, 1, 0]);
|
2019-05-05 23:32:30 +00:00
|
|
|
var animating = false;
|
2019-05-07 05:57:32 +00:00
|
|
|
var opened = false;
|
2019-04-19 01:15:05 +00:00
|
|
|
|
2019-06-24 00:30:12 +00:00
|
|
|
Self.SetHitbox(16, 0, 32, 64);
|
|
|
|
|
|
|
|
Message.Subscribe("power", function(powered) {
|
2020-04-22 06:50:45 +00:00
|
|
|
console.log("%s got power=%+v", Self.Title, powered);
|
2019-06-24 00:30:12 +00:00
|
|
|
|
|
|
|
if (powered) {
|
|
|
|
if (animating || opened) {
|
|
|
|
return;
|
|
|
|
}
|
2019-04-19 01:15:05 +00:00
|
|
|
|
2019-05-07 05:57:32 +00:00
|
|
|
animating = true;
|
2020-05-23 03:07:48 +00:00
|
|
|
Sound.Play("electric-door.wav")
|
2019-05-07 05:57:32 +00:00
|
|
|
Self.PlayAnimation("open", function() {
|
|
|
|
opened = true;
|
|
|
|
animating = false;
|
|
|
|
});
|
2019-06-24 00:30:12 +00:00
|
|
|
} else {
|
|
|
|
animating = true;
|
2020-05-23 03:07:48 +00:00
|
|
|
Sound.Play("electric-door.wav")
|
2019-05-07 05:57:32 +00:00
|
|
|
Self.PlayAnimation("close", function() {
|
2019-12-31 02:13:28 +00:00
|
|
|
opened = false;
|
2019-06-24 00:30:12 +00:00
|
|
|
animating = false;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Events.OnCollide(function(e) {
|
|
|
|
if (e.InHitbox) {
|
|
|
|
if (!opened) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-05-07 05:57:32 +00:00
|
|
|
}
|
2019-06-24 00:30:12 +00:00
|
|
|
});
|
2019-04-19 01:15:05 +00:00
|
|
|
}
|