Noah Petherbridge
7b3aec0fef
* Two-state Buttons now also subscribe to the state change message, so other on/off buttons in the same level update to match the state of the button that was hit. * Add lock mutexes around the scripting engine to protect from concurrent event handlers.
24 lines
414 B
JavaScript
24 lines
414 B
JavaScript
// Orange State Block
|
|
function main() {
|
|
Self.SetHitbox(0, 0, 33, 33);
|
|
|
|
// Orange block is OFF by default.
|
|
var state = false;
|
|
|
|
Message.Subscribe("broadcast:state-change", function(newState) {
|
|
state = newState;
|
|
|
|
// Layer 0: OFF
|
|
// Layer 1: ON
|
|
Self.ShowLayer(state ? 1 : 0);
|
|
});
|
|
|
|
Events.OnCollide(function(e) {
|
|
if (e.Actor.IsMobile() && e.InHitbox) {
|
|
if (state) {
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
}
|