doodle/dev-assets/doodads/regions/reset-timer.js
Noah Petherbridge 38a23f00b2 Reset Timer Doodad + Various Fixes
* Bird is not solid when colliding with other birds.
* If the dev shell is used to run JavaScript during Play Mode, consider
  it cheating (so player can't `$ d.Scene.ResetTimer()` for example)
* On Survival Mode levels, DieByFire immediately opens the End Level
  (silver score) modal rather than respawn from checkpoint, so levels
  don't need checkpoint contraptions to end the level.
* During level loading screens, wait and call doodads' main() function
  until the very end.
2022-03-27 11:51:14 -07:00

31 lines
605 B
JavaScript

// Reset Level Timer.
function main() {
Self.Hide();
// Reset the level timer only once.
let hasReset = false;
Events.OnCollide((e) => {
if (!e.Settled) {
return;
}
// Only care if it's the player.
if (!e.Actor.IsPlayer()) {
return;
}
if (e.InHitbox && !hasReset) {
Level.ResetTimer();
hasReset = true;
}
});
// Receive a power signal resets the doodad.
Message.Subscribe("power", (powered) => {
if (powered) {
hasReset = true;
}
});
}