diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d2ae1fc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.doodad diff --git a/build.sh b/build.sh index a668a3e..017fd72 100755 --- a/build.sh +++ b/build.sh @@ -74,6 +74,10 @@ objects() { cd regions/ make cd .. + + # cd test/ + # make + # cd .. } onoff() { diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..e378aff --- /dev/null +++ b/test/Makefile @@ -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/ diff --git a/test/exceptions.js b/test/exceptions.js new file mode 100644 index 0000000..dfd60d4 --- /dev/null +++ b/test/exceptions.js @@ -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!`); + }); +} diff --git a/test/exceptions.png b/test/exceptions.png new file mode 100644 index 0000000..1b78143 Binary files /dev/null and b/test/exceptions.png differ diff --git a/test/mischievous.js b/test/mischievous.js new file mode 100644 index 0000000..f4c18d1 --- /dev/null +++ b/test/mischievous.js @@ -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() { + + }) +} diff --git a/test/mischievous.png b/test/mischievous.png new file mode 100644 index 0000000..001b6e4 Binary files /dev/null and b/test/mischievous.png differ