2021-10-03 03:52:16 +00:00
|
|
|
// Stall Player.
|
|
|
|
// Tags: ms (int)
|
|
|
|
// Grabs the player one time. Resets if it receives power.
|
|
|
|
function main() {
|
|
|
|
Self.Hide();
|
|
|
|
|
2022-01-17 04:09:27 +00:00
|
|
|
let active = true,
|
2021-10-03 03:52:16 +00:00
|
|
|
timeout = 250,
|
|
|
|
ms = Self.GetTag("ms");
|
|
|
|
|
|
|
|
if (ms.length > 0) {
|
|
|
|
timeout = parseInt(ms);
|
|
|
|
}
|
|
|
|
|
2022-01-17 04:09:27 +00:00
|
|
|
Events.OnCollide((e) => {
|
2021-10-03 03:52:16 +00:00
|
|
|
if (!active || !e.Settled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only care if it's the player.
|
|
|
|
if (!e.Actor.IsPlayer()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e.InHitbox) {
|
|
|
|
// Grab hold of the player.
|
|
|
|
e.Actor.Freeze();
|
2022-01-17 04:09:27 +00:00
|
|
|
setTimeout(() => {
|
2021-10-03 03:52:16 +00:00
|
|
|
e.Actor.Unfreeze();
|
|
|
|
}, timeout);
|
|
|
|
|
|
|
|
active = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Reset the trap if powered by a button.
|
2022-01-17 04:09:27 +00:00
|
|
|
Message.Subscribe("power", (powered) => {
|
2021-10-03 03:52:16 +00:00
|
|
|
active = true;
|
|
|
|
});
|
|
|
|
}
|