2019-04-19 01:15:05 +00:00
|
|
|
function main() {
|
2019-05-05 23:32:30 +00:00
|
|
|
Self.AddAnimation("open", 0, [1]);
|
|
|
|
var unlocked = false;
|
|
|
|
|
2019-06-24 00:30:12 +00:00
|
|
|
// Self.Canvas.SetBackground(RGBA(0, 255, 255, 100));
|
2019-06-09 00:02:28 +00:00
|
|
|
|
2019-05-29 04:43:30 +00:00
|
|
|
// Map our door names to key names.
|
|
|
|
var KeyMap = {
|
|
|
|
"Blue Door": "Blue Key",
|
|
|
|
"Red Door": "Red Key",
|
|
|
|
"Green Door": "Green Key",
|
|
|
|
"Yellow Door": "Yellow Key"
|
|
|
|
}
|
2019-05-07 05:57:32 +00:00
|
|
|
|
2019-06-24 00:30:12 +00:00
|
|
|
// log.Warn("%s loaded!", Self.Doodad.Title);
|
|
|
|
// console.log("%s Setting hitbox", Self.Doodad.Title);
|
2019-05-29 04:43:30 +00:00
|
|
|
Self.SetHitbox(16, 0, 32, 64);
|
2019-05-07 05:57:32 +00:00
|
|
|
|
2019-05-29 04:43:30 +00:00
|
|
|
Events.OnCollide(function(e) {
|
2019-05-05 23:32:30 +00:00
|
|
|
if (unlocked) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-29 04:43:30 +00:00
|
|
|
if (e.InHitbox) {
|
|
|
|
var data = e.Actor.GetData("key:" + KeyMap[Self.Doodad.Title]);
|
|
|
|
if (data === "") {
|
|
|
|
// Door is locked.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
unlocked = true;
|
|
|
|
Self.PlayAnimation("open", null);
|
|
|
|
}
|
2019-04-19 01:15:05 +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)
|
|
|
|
// })
|
2019-04-19 01:15:05 +00:00
|
|
|
}
|