2019-12-31 02:13:28 +00:00
|
|
|
// Blue State Block
|
|
|
|
function main() {
|
2020-12-30 04:31:35 +00:00
|
|
|
Self.SetHitbox(0, 0, 42, 42);
|
2019-12-31 02:13:28 +00:00
|
|
|
|
|
|
|
// Blue block is ON by default.
|
2022-01-17 04:09:27 +00:00
|
|
|
let state = true;
|
2019-12-31 02:13:28 +00:00
|
|
|
|
2022-01-17 04:09:27 +00:00
|
|
|
Message.Subscribe("broadcast:state-change", (newState) => {
|
2019-12-31 02:13:28 +00:00
|
|
|
state = !newState;
|
|
|
|
|
|
|
|
// Layer 0: ON
|
|
|
|
// Layer 1: OFF
|
2020-01-03 01:58:22 +00:00
|
|
|
Self.ShowLayer(state ? 0 : 1);
|
2019-12-31 02:13:28 +00:00
|
|
|
});
|
|
|
|
|
2022-01-17 04:09:27 +00:00
|
|
|
Events.OnCollide((e) => {
|
2019-12-31 02:13:28 +00:00
|
|
|
if (e.Actor.IsMobile() && e.InHitbox) {
|
|
|
|
if (state) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|