Anvil and Camera Focus doodads

master
Noah 2022-09-24 23:55:30 -07:00
parent 319e5c0a25
commit 4d960f4d2d
4 changed files with 48 additions and 0 deletions

View File

@ -14,6 +14,7 @@ function main() {
let nowAt = Self.Position();
if (nowAt.Y > lastPoint.Y) {
falling = true;
Self.CameraFollowMe();
} else {
falling = false;
}

View File

@ -23,6 +23,10 @@ build:
doodad convert -t "Power Source" power-64.png power-source.doodad
doodad install-script power.js power-source.doodad
# Look At Me
doodad convert -t "Look At Me" camera-focus.png camera-focus.doodad
doodad install-script camera-focus.js camera-focus.doodad
# Warp Door
doodad convert -t "Invisible Warp Door" warp-door-64.png reg-warp-door.doodad
doodad edit-doodad --tag "color=invisible" reg-warp-door.doodad

43
regions/camera-focus.js Normal file
View File

@ -0,0 +1,43 @@
// Camera Region
//
// When it receives power, it attracts the camera's focus for a while.
// configuration
const ticksToInsist = 24;
let powered = false;
function main() {
Self.Hide();
let timer = null;
Message.Subscribe("power", (v) => {
if (powered && !v) {
// Lost power, we can do this again next time.
powered = false;
if (timer !== null) {
clearInterval(timer);
timer = null;
}
return;
}
// Look at me!
Self.CameraFollowMe();
// And insist a while.
if (timer === null) {
let insistUntil = GetTick() + ticksToInsist;
timer = setInterval(() => {
if (GetTick() < insistUntil) {
Self.CameraFollowMe();
} else {
clearInterval(timer);
}
}, 10);
}
powered = v;
})
}

BIN
regions/camera-focus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B