From 319e5c0a253f17e160d83982644335b5ca71dbab Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 24 Sep 2022 22:00:17 -0700 Subject: [PATCH] Some test doodads --- .gitignore | 1 + build.sh | 4 ++++ test/Makefile | 16 ++++++++++++++++ test/exceptions.js | 27 +++++++++++++++++++++++++++ test/exceptions.png | Bin 0 -> 1387 bytes test/mischievous.js | 30 ++++++++++++++++++++++++++++++ test/mischievous.png | Bin 0 -> 986 bytes 7 files changed, 78 insertions(+) create mode 100644 .gitignore create mode 100644 test/Makefile create mode 100644 test/exceptions.js create mode 100644 test/exceptions.png create mode 100644 test/mischievous.js create mode 100644 test/mischievous.png 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 0000000000000000000000000000000000000000..1b78143133e28978aef22aecb6a94f522917d47b GIT binary patch literal 1387 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrU~I{Bb`J1#c2+1T%1_J8No8Qr zm{>c}*5j~)%+dJEU7=cBWdVgJ0_N&;bXjDHb_FcF!nM|FM$9i(U#UqV;_e5xK6r3E z>FU9wk>Tv&jskxe3QLNDN+t^ZpDq%0q@v(XfBAR0^7jl21 zk2f8v?A{!;ZqqZ{pWM!txv4W>o3slaSDH4Vg+nrQNuKLTX{iAZf{KabTQx?(t z(zpIRTzp`yV#DmuGsik=I8v^m-kGo>%Jkk(s@gr_sig~J~#j77MHl0yU97|UB2>uWy${a*W*3^Sx$TN zt9I`{yQfn*l75w+Tlap;#b2&+x4ztpxwl+~sc+N03DpMfoAoale`GXrz8EUL`&w7h zo4|?^p4Xv2ucdxDx4-p7IQIhA)S`U{uk5&%d_#<1W%~b%teZmS7oKLa=e_F8;+}b7 zGcWV`)#g{e-?)FNaaR+^eD~ld^Y|WJd^7L0W%PcJaI%vzw z!c*Uu_20Sgof-UnNsdNu%&XEvZf7}_ykB0QBd}>(t&??gmj64Cw-rCvd8~T0Q`qg> zvTrOCm%g4T>{Rqqzwp%51G|stSt+JCUyLceUQou-;lk?9=kVfYgXzT6#nJ}PcU_SB zeZI`$$d!9)b_bR-W=k7A(vkgG&^hUz>i17;Rz~~&dLGsrFuVN7@3n6qRewzi{ylx$ zrS)4Es{LJA(;zi*YQ?L)Z{w|P*PQ)d!nC4RdHaV&+eOagskf|&?dhD;Aox+Y&yH7T zW8piONmstU)YQJXP1`o`%Dn^9N%;zJUo)7inY?}d^W-Fte@o+4R?ggiey!t@94+1% zC#PC&@4HYfo6=(zwBCQ3OyjLzYdq_xG|Wi<@^F3N$IzCG#hPXO2g?eXvRwvfb=}$om4xKi?ZMI|my91QDZSmpT=tRinpIQ#znqxU8?+7|`0uoWx8tQ=!{U9e zYhPde^>|wK_KU^-`agU&_t@s#T6D&6(XPGrk&~i%R>tbww60xQeD{+i2ggoDCMN@M z3^_2&YG80+fFxINQ~`+?ZoH8RiqC9CtsiY2T*n|<88eu`@ebnM>2W{%+-LFkX;TWf j)tt}TEXTmokobfBz}lMUOnp0!gY58h^>bP0l+XkK)#Y-z literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..001b6e41307a4af50e6b57c94393b7e74503200a GIT binary patch literal 986 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrU~I{Bb`J1#c2+1T%1_J8No8Qr zm{>c}*5j~)%+dJEU7=cBWdVgJ0_N&;bXjDHb_FcF!nM|FM$9i(U#UqV;_e5xK6r3E z>FU9wk>Tv&jskxe3QLNDN+t^ZpDq%0q@v(XfBAR0^7jl21 zk2f8v?A{!;ZqqZ{pWM!txv4W>o3slaSDH4Vg+nrQNchr%GYj7_xay_GRMnn?tfv?eS9%_H;dNq zKdq)v`gq-{Ii;3K{_p=-K0g~&6j#e|E0d{j$-fslk1wk0T|2(R>+I&W$$8P%+oP-h zosD|8dHG-OQmyRTr**G>o!1Hv6fRhDVST1l-@PN#uGakR&sSZ)Y<6*|WcHqa!ORo9 zs@8=6?Nv|7-XkZiI_GZr&O-rKeY!I{R@N$MY@fXCYxS#NS@SuV7#OOOLkrs1aH(-H zFf}l6G-v_6$-oHmEf_qATf_BkLg+yjun=PaD^QUF16VCYfq7D7MY|5SI*HmLn(uUn z9+cgrH3Mv-0>dhBAcJgwac2L@2STcskEuS-c)Mfmw42flj0!FGyh3Sb*6mh)2GZ^6 L>gTe~DWM4fT1=m7 literal 0 HcmV?d00001