2019-04-17 07:02:41 +00:00
|
|
|
function main() {
|
2019-04-19 01:15:05 +00:00
|
|
|
console.log("%s initialized!", Self.Doodad.Title);
|
2019-04-17 07:02:41 +00:00
|
|
|
|
2019-05-07 05:57:32 +00:00
|
|
|
var pressed = false;
|
|
|
|
|
2019-06-24 00:30:12 +00:00
|
|
|
// When a sticky button receives power, it pops back up.
|
|
|
|
Message.Subscribe("power", function(powered) {
|
|
|
|
if (powered && pressed) {
|
|
|
|
Self.ShowLayer(0);
|
|
|
|
pressed = false;
|
|
|
|
Message.Publish("power", false);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-05-07 05:57:32 +00:00
|
|
|
Events.OnCollide(function(e) {
|
|
|
|
if (pressed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify they've touched the button.
|
|
|
|
if (e.Overlap.Y + e.Overlap.H < 24) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-19 01:15:05 +00:00
|
|
|
Self.ShowLayer(1);
|
2019-05-07 05:57:32 +00:00
|
|
|
pressed = true;
|
2019-06-24 00:30:12 +00:00
|
|
|
Message.Publish("power", true);
|
2019-05-07 05:57:32 +00:00
|
|
|
});
|
2019-04-17 07:02:41 +00:00
|
|
|
}
|