doodle/dev-assets/doodads/regions/power.js
Noah Petherbridge 4d08bf1d85 Switch JavaScript engine to goja
* Switch from otto to goja for JavaScript engine.
* goja supports many ES6 syntax features like arrow functions,
  const/let, for-of with more coming soon.
* Same great features as otto, more modern environment for doodads!
2022-01-16 20:09:27 -08:00

23 lines
711 B
JavaScript

// Power source.
// Emits a power(true) signal once on level start.
// If it receives a power signal, it will repeat it after 5 seconds.
// Link two of these bad boys together and you got yourself a clock.
function main() {
Self.Hide();
// See if we are not linked to anything.
var links = Self.GetLinks();
if (links.length === 0) {
console.error(
"%s at %s is not linked to anything! This doodad emits a power(true) on level start to all linked doodads.",
Self.Title,
Self.Position()
);
}
Message.Subscribe("broadcast:ready", () => {
Message.Publish("switch:toggle", true);
Message.Publish("power", true);
});
}