Polish and bugfixes

- Fix a memory sharing bug in the Giant Screenshot feature.
- Main Menu to eagerload chunks in the background to make scrolling less
  jittery. No time for a loadscreen!
- Extra script debugging: names/IDs of doodads are shown when they send
  messages to one another.
- Level Properties: you can edit the Bounded max width/height values for
  the level.

Doodad changes:

- Buttons: fix a timing bug and keep better track of who is stepping on it,
  only popping up when all colliders have left. The effect: they pop up
  immediately (not after 200ms) and are more reliable.
- Keys: zero-qty keys will no longer put themselves into the inventory of
  characters who already have one except for the player character. So
  the Thief will not steal them if she already has the key.

Added to the JavaScript API:

* time.Hour, time.Minute, time.Second, time.Millisecond, time.Microsecond
master
Noah 2021-10-09 20:45:38 -07:00
parent 36684f99f1
commit 73175b6965
3 changed files with 27 additions and 11 deletions

View File

@ -4,16 +4,23 @@ function main() {
// Has a linked Sticky Button been pressed permanently down?
var stickyDown = false;
Message.Subscribe("sticky:down", function(down) {
Message.Subscribe("sticky:down", function (down) {
stickyDown = down;
Self.ShowLayer(stickyDown ? 1 : 0);
});
Events.OnCollide(function(e) {
// Track who all is colliding with us.
var colliders = {};
Events.OnCollide(function (e) {
if (!e.Settled) {
return;
}
if (colliders[e.Actor.ID()] == undefined) {
colliders[e.Actor.ID()] = true;
}
// If a linked Sticky Button is pressed, button stays down too and
// doesn't interact.
if (stickyDown) {
@ -37,12 +44,17 @@ function main() {
}
Self.ShowLayer(1);
timer = setTimeout(function() {
});
Events.OnLeave(function (e) {
delete colliders[e.Actor.ID()];
if (Object.keys(colliders).length === 0) {
Sound.Play("button-up.wav")
Self.ShowLayer(0);
Message.Publish("power", false);
timer = 0;
pressed = false;
}, 200);
}
});
}

View File

@ -6,7 +6,6 @@ var powerState = false;
function setPoweredState(powered) {
powerState = powered;
console.log("setPoweredState: %+v", powered)
if (powered) {
if (animating || opened) {
return;
@ -14,14 +13,14 @@ function setPoweredState(powered) {
animating = true;
Sound.Play("electric-door.wav")
Self.PlayAnimation("open", function() {
Self.PlayAnimation("open", function () {
opened = true;
animating = false;
});
} else {
animating = true;
Sound.Play("electric-door.wav")
Self.PlayAnimation("close", function() {
Self.PlayAnimation("close", function () {
opened = false;
animating = false;
})
@ -41,13 +40,12 @@ function main() {
// power sources like Buttons will work as normal, as they emit only a power
// signal.
var ignoreNextPower = false;
Message.Subscribe("switch:toggle", function(powered) {
console.log("A switch powered %+v, setPoweredState(%+v) to opposite", powered, powerState);
Message.Subscribe("switch:toggle", function (powered) {
ignoreNextPower = true;
setPoweredState(!powerState);
})
Message.Subscribe("power", function(powered) {
Message.Subscribe("power", function (powered) {
if (ignoreNextPower) {
ignoreNextPower = false;
return;
@ -56,7 +54,7 @@ function main() {
setPoweredState(powered);
});
Events.OnCollide(function(e) {
Events.OnCollide(function (e) {
if (e.InHitbox) {
if (!opened) {
return false;

View File

@ -5,6 +5,12 @@ function main() {
Events.OnCollide(function (e) {
if (e.Settled) {
if (e.Actor.HasInventory()) {
// If we don't have a quantity, and the actor already has
// one of us, don't pick it up so the player can get it.
if (quantity === 0 && e.Actor.HasItem(Self.Filename) === 0 && !e.Actor.IsPlayer()) {
return;
}
Sound.Play("item-get.wav")
e.Actor.AddItem(Self.Filename, quantity);
Self.Destroy();