Technical Doodad: Checkpoint Region

The Checkpoint Region acts as an invisible checkpoint flag, remembering
the player's location should they need to respawn there.

New cheat: `show all actors` during Play Mode will make every hidden
actor visible. Useful to see your technical doodads during gameplay!

Developer shell: `Execute(command string)` is available to the
JavaScript interpreter. It simulates another command being run on the
developer console.
This commit is contained in:
Noah 2021-10-02 21:12:57 -07:00
parent ed925b9ace
commit 7702406579
3 changed files with 42 additions and 0 deletions

View File

@ -6,6 +6,10 @@ build:
doodad convert -t "Goal Region" goal-128.png reg-goal.doodad
doodad install-script goal.js reg-goal.doodad
# Checkpoint Region
doodad convert -t "Checkpoint Region" checkpoint-128.png reg-checkpoint.doodad
doodad install-script checkpoint.js reg-checkpoint.doodad
# Fire Region
doodad convert -t "Fire Region" fire-128.png reg-fire.doodad
doodad install-script fire.js reg-fire.doodad

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

View File

@ -0,0 +1,38 @@
// Checkpoint Region
// Acts like an invisible checkpoint flag.
var isCurrentCheckpoint = false;
function main() {
Self.Hide();
setActive(false);
// Checkpoints broadcast to all of their peers so they all
// know which one is the most recently activated.
Message.Subscribe("broadcast:checkpoint", function (currentID) {
setActive(false);
});
Events.OnCollide(function (e) {
if (isCurrentCheckpoint || !e.Settled) {
return;
}
// Only care about the player character.
if (!e.Actor.IsPlayer()) {
return;
}
// Set the player checkpoint.
SetCheckpoint(Self.Position());
setActive(true);
Message.Broadcast("broadcast:checkpoint", Self.ID())
});
}
function setActive(v) {
if (v && !isCurrentCheckpoint) {
Flash("Checkpoint!");
}
isCurrentCheckpoint = v;
}