Noah Petherbridge
4d08bf1d85
* 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!
24 lines
399 B
JavaScript
24 lines
399 B
JavaScript
// Blue State Block
|
|
function main() {
|
|
Self.SetHitbox(0, 0, 42, 42);
|
|
|
|
// Blue block is ON by default.
|
|
let state = true;
|
|
|
|
Message.Subscribe("broadcast:state-change", (newState) => {
|
|
state = !newState;
|
|
|
|
// Layer 0: ON
|
|
// Layer 1: OFF
|
|
Self.ShowLayer(state ? 0 : 1);
|
|
});
|
|
|
|
Events.OnCollide((e) => {
|
|
if (e.Actor.IsMobile() && e.InHitbox) {
|
|
if (state) {
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
}
|