Add files via upload

Fixed bug causing game to not load, #10 needs to be semi re-implemented
This commit is contained in:
Damian Idzinski
2025-02-02 01:31:21 +00:00
committed by GitHub
parent 33c6def8bb
commit 403a3d345e

View File

@@ -1406,52 +1406,35 @@
let message = `${data.name}\n\n`;
message += `Observations: ${data.observations}\n\n`;
if (distanceSq > INTERACTION_RANGE_SQ) {
// Check for locked state in scenarioData
if (data.locked === true) {
console.log('Item is locked:', data);
handleUnlock(sprite, 'item');
return;
}
}
const data = sprite.scenarioData;
let message = `${data.name}\n\n`;
message += `Observations: ${data.observations}\n\n`;
// Check for locked state in scenarioData
if (data.locked === true) {
console.log('Item is locked:', data);
handleUnlock(sprite, 'item');
return;
}
if (data.readable && data.text) {
message += `Text: ${data.text}\n\n`;
}
// Only handle contents if they exist and haven't been collected yet
if (data.contents && data.contents.length > 0) {
message += `You found the following items:\n`;
data.contents.forEach(item => {
message += `- ${item.name}\n`;
});
alert(message);
// Add all contents to inventory
data.contents.forEach(item => {
const contentSprite = createInventorySprite({
...item,
type: item.type.toLowerCase()
if (data.readable && data.text) {
message += `Text: ${data.text}\n\n`;
}
if (data.contents && data.contents.length > 0) {
message += `You found the following items:\n`;
data.contents.forEach(item => {
message += `- ${item.name}\n`;
});
alert(message);
// Add all contents to inventory
data.contents.forEach(item => {
// Ensure the item type matches the preloaded asset name
const contentSprite = createInventorySprite(item);
const contentSprite = createInventorySprite({
...item,
type: item.type.toLowerCase()
});
if (contentSprite) {
addToInventory(contentSprite);
}
});
// Clear contents after adding to inventory
data.contents = [];
return;
@@ -1875,24 +1858,17 @@
lockable.isUnlockedButNotCollected = true;
}
}
}
}
function collectContainerContents(container) {
if (!container.scenarioData?.contents ||
!container.scenarioData?.isUnlockedButNotCollected) {
return;
}
container.scenarioData.contents.forEach(item => {
const sprite = createInventorySprite(item);
if (sprite) {
addToInventory(sprite);
// If the item has contents, make them accessible
if (lockable.scenarioData?.contents) {
lockable.scenarioData.contents.forEach(item => {
const sprite = createInventorySprite(item);
if (sprite) {
addToInventory(sprite);
}
});
}
});
container.scenarioData.isUnlockedButNotCollected = false;
alert('You collected the items from the container.');
}
}
// Helper function to create inventory sprites for unlocked container contents
@@ -2071,6 +2047,23 @@
};
}
function collectContainerContents(container) {
if (!container.scenarioData?.contents ||
!container.scenarioData?.isUnlockedButNotCollected) {
return;
}
container.scenarioData.contents.forEach(item => {
const sprite = createInventorySprite(item);
if (sprite) {
addToInventory(sprite);
}
});
container.scenarioData.isUnlockedButNotCollected = false;
alert('You collected the items from the container.');
}
</script>
</body>
</html>