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);
|
|
|
|
|
|
|
|
var timer = 0;
|
2019-04-17 07:02:41 +00:00
|
|
|
|
2019-05-07 05:57:32 +00:00
|
|
|
Events.OnCollide(function(e) {
|
|
|
|
// Verify they've touched the button.
|
|
|
|
if (e.Overlap.Y + e.Overlap.H < 24) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-24 00:30:12 +00:00
|
|
|
Message.Publish("power", true);
|
2019-05-07 05:57:32 +00:00
|
|
|
|
2019-04-19 01:15:05 +00:00
|
|
|
if (timer > 0) {
|
|
|
|
clearTimeout(timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
Self.ShowLayer(1);
|
|
|
|
timer = setTimeout(function() {
|
|
|
|
Self.ShowLayer(0);
|
2019-06-24 00:30:12 +00:00
|
|
|
Message.Publish("power", false);
|
2019-04-19 01:15:05 +00:00
|
|
|
timer = 0;
|
|
|
|
}, 200);
|
2019-05-07 05:57:32 +00:00
|
|
|
});
|
|
|
|
|
2019-06-24 00:30:12 +00:00
|
|
|
// Events.OnLeave(function(e) {
|
|
|
|
// console.log("%s has stopped touching %s", e, Self.Doodad.Title)
|
|
|
|
// Self.Canvas.SetBackground(RGBA(0, 0, 1, 0));
|
|
|
|
// })
|
2019-04-17 07:02:41 +00:00
|
|
|
}
|