Some test doodads

This commit is contained in:
Noah 2022-09-24 22:00:17 -07:00
parent 4c07ffc801
commit 319e5c0a25
7 changed files with 78 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.doodad

View File

@ -74,6 +74,10 @@ objects() {
cd regions/ cd regions/
make make
cd .. cd ..
# cd test/
# make
# cd ..
} }
onoff() { onoff() {

16
test/Makefile Normal file
View File

@ -0,0 +1,16 @@
ALL: build
.PHONY: build
build:
# Mischievous JS script tests.
doodad convert -t "Mischievous Script Test" mischievous.png TEST-mischievous.doodad
doodad install-script mischievous.js TEST-mischievous.doodad
# Exception raiser.
doodad convert -t "Exception Raiser Test" exceptions.png TEST-exceptions.doodad
doodad install-script exceptions.js TEST-exceptions.doodad
for i in *.doodad; do\
doodad edit-doodad --tag "category=technical" --hide $${i};\
done
cp *.doodad ../../../assets/doodads/

27
test/exceptions.js Normal file
View File

@ -0,0 +1,27 @@
// Test Doodad Script
function main() {
console.log("I am actor ID " + Self.ID());
// Helper function to raise an exception w/ a backoff.
let busy = false,
raise = function(message) {
if (busy) return;
setTimeout(() => {
busy = false;
}, 1000);
busy = true;
throw message;
};
Events.OnCollide( function(e) {
console.log("Collided with something!");
raise(`Collided with ${e.Actor.Drawing.Doodad.Title}!\n`+
`Settled: ${e.Settled} Overlap: ${e.Overlap}\n`+
`Is Player: ${e.Actor.IsPlayer()}\n`+
`Inventory: ${JSON.stringify(Object.keys(e.Actor.Inventory()))}`);
});
Message.Subscribe("power", (powered) => {
raise(`Received a power (${powered}) signal!`);
});
}

BIN
test/exceptions.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

30
test/mischievous.js Normal file
View File

@ -0,0 +1,30 @@
function main() {
console.log("%s initialized!", Self.Title);
console.log(Object.keys(console));
var colors = [
RGBA(255, 0, 0, 255),
RGBA(255, 153, 0, 255),
RGBA(255, 255, 0, 255),
RGBA(0, 255, 0, 255),
RGBA(0, 153, 255, 255),
RGBA(0, 0, 255, 255),
RGBA(255, 0, 255, 255)
];
var colorIndex = 0;
setInterval(function() {
// console.log("sticky tick");
Self.Canvas.MaskColor = colors[colorIndex];
colorIndex++;
if (colorIndex == colors.length) {
colorIndex = 0;
}
}, 100);
// log.Config.Colors = 0; // panics, can't set a golog.Color
Events.OnCollide( function() {
})
}

BIN
test/mischievous.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 986 B