Some test doodads
This commit is contained in:
parent
4c07ffc801
commit
319e5c0a25
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.doodad
|
4
build.sh
4
build.sh
|
@ -74,6 +74,10 @@ objects() {
|
|||
cd regions/
|
||||
make
|
||||
cd ..
|
||||
|
||||
# cd test/
|
||||
# make
|
||||
# cd ..
|
||||
}
|
||||
|
||||
onoff() {
|
||||
|
|
16
test/Makefile
Normal file
16
test/Makefile
Normal 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
27
test/exceptions.js
Normal 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
BIN
test/exceptions.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
30
test/mischievous.js
Normal file
30
test/mischievous.js
Normal 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
BIN
test/mischievous.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 986 B |
Loading…
Reference in New Issue
Block a user