Skip to content

Commit

Permalink
Ensure task copied inventory is named correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMettam committed Nov 22, 2023
1 parent 05dac2d commit 67add23
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 15 deletions.
130 changes: 120 additions & 10 deletions lib/classes/commands/RegionCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,18 @@ export class RegionCommands extends CommandsBase
const item = buildMap.assetMap.clothing[invItem.assetID.toString()].item;
if (item !== null)
{
await object.dropInventoryIntoContents(item, invItem.name);
await object.dropInventoryIntoContents(item);
if (invItem.name !== item.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === item.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
}
break;
Expand All @@ -857,7 +868,18 @@ export class RegionCommands extends CommandsBase
const item = buildMap.assetMap.settings[invItem.assetID.toString()].item;
if (item !== null)
{
await object.dropInventoryIntoContents(item, invItem.name);
await object.dropInventoryIntoContents(item);
if (invItem.name !== item.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === item.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
}
break;
Expand All @@ -870,7 +892,18 @@ export class RegionCommands extends CommandsBase
const item = buildMap.assetMap.bodyparts[invItem.assetID.toString()].item;
if (item !== null)
{
await object.dropInventoryIntoContents(item, invItem.name);
await object.dropInventoryIntoContents(item);
if (invItem.name !== item.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === item.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
}
break;
Expand All @@ -882,7 +915,18 @@ export class RegionCommands extends CommandsBase
const item = buildMap.assetMap.notecards[invItem.assetID.toString()].item;
if (item !== null)
{
await object.dropInventoryIntoContents(item, invItem.name);
await object.dropInventoryIntoContents(item);
if (invItem.name !== item.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === item.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
}
break;
Expand All @@ -894,7 +938,18 @@ export class RegionCommands extends CommandsBase
const item = buildMap.assetMap.sounds[invItem.assetID.toString()].item;
if (item !== null)
{
await object.dropInventoryIntoContents(item, invItem.name);
await object.dropInventoryIntoContents(item);
if (invItem.name !== item.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === item.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
}
break;
Expand All @@ -906,7 +961,18 @@ export class RegionCommands extends CommandsBase
const item = buildMap.assetMap.gestures[invItem.assetID.toString()].item;
if (item !== null)
{
await object.dropInventoryIntoContents(item, invItem.name);
await object.dropInventoryIntoContents(item);
if (invItem.name !== item.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === item.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
}
break;
Expand All @@ -919,7 +985,18 @@ export class RegionCommands extends CommandsBase
const item = buildMap.assetMap.scripts[invItem.assetID.toString()].item;
if (item !== null)
{
await object.dropInventoryIntoContents(item, invItem.name);
await object.dropInventoryIntoContents(item);
if (invItem.name !== item.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === item.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
}
break;
Expand All @@ -931,7 +1008,18 @@ export class RegionCommands extends CommandsBase
const item = buildMap.assetMap.animations[invItem.assetID.toString()].item;
if (item !== null)
{
await object.dropInventoryIntoContents(item, invItem.name);
await object.dropInventoryIntoContents(item);
if (invItem.name !== item.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === item.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
}
break;
Expand All @@ -943,7 +1031,18 @@ export class RegionCommands extends CommandsBase
const inventoryItem = buildMap.assetMap.objects[invItem.itemID.toString()];
if (inventoryItem !== null)
{
await object.dropInventoryIntoContents(inventoryItem, invItem.name);
await object.dropInventoryIntoContents(inventoryItem);
if (invItem.name !== inventoryItem.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === inventoryItem.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
else
{
Expand All @@ -960,7 +1059,18 @@ export class RegionCommands extends CommandsBase
const texItem = buildMap.assetMap.textures[invItem.assetID.toString()];
if (texItem.item !== null)
{
await object.dropInventoryIntoContents(texItem.item, invItem.name);
await object.dropInventoryIntoContents(texItem.item);
if (invItem.name !== texItem.item.name)
{
await object.updateInventory();
for (const taskItem of object.inventory)
{
if (taskItem.name === texItem.item.name)
{
await taskItem.renameInTask(object, invItem.name);
}
}
}
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/public/GameObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ export class GameObject implements IGameObjectData
return GameObject.takeManyToInventory(this.region, [this], folder);
}

async dropInventoryIntoContents(inventoryItem: InventoryItem | UUID, newName?: string): Promise<void>
async dropInventoryIntoContents(inventoryItem: InventoryItem | UUID): Promise<void>
{
const transactionID = UUID.zero();

Expand Down Expand Up @@ -2043,7 +2043,7 @@ export class GameObject implements IGameObjectData
Flags: inventoryItem.flags,
SaleType: inventoryItem.saleType,
SalePrice: inventoryItem.salePrice,
Name: Utils.StringToBuffer(newName ?? inventoryItem.name),
Name: Utils.StringToBuffer(inventoryItem.name),
Description: Utils.StringToBuffer(inventoryItem.description),
CreationDate: inventoryItem.created.getTime() / 1000,
CRC: inventoryItem.getCRC()
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@caspertech/node-metaverse",
"version": "0.7.7",
"version": "0.7.9",
"description": "A node.js interface for Second Life.",
"main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",
Expand Down

0 comments on commit 67add23

Please sign in to comment.