Resolves #47: Use LSL Inventory type when uploading scripts. Thanks to @xBorus
This commit is contained in:
@@ -24,6 +24,7 @@ class Inventory extends ExampleBot
|
||||
|
||||
const exampleFolderName = 'node-metaverse example';
|
||||
const exampleNotecardName = 'Example Notecard';
|
||||
const exampleScriptName = 'Example script';
|
||||
|
||||
let exampleFolder: InventoryFolder | undefined = undefined;
|
||||
for (const childFolder of rootFolder.folders)
|
||||
@@ -66,6 +67,21 @@ class Inventory extends ExampleBot
|
||||
exampleNotecard.permissions.nextOwnerMask = PermissionMask.Transfer | PermissionMask.Modify;
|
||||
await exampleNotecard.update();
|
||||
|
||||
let exampleScript = exampleFolder.items.find(f => f.name === exampleScriptName);
|
||||
if (exampleScript === undefined)
|
||||
{
|
||||
exampleScript = await exampleFolder.uploadAsset(
|
||||
AssetType.LSLText,
|
||||
InventoryType.LSL,
|
||||
Buffer.from(
|
||||
'default { touch_start(integer total_number) { llSay(0, "Hello, world!"); } } '
|
||||
, 'utf-8'
|
||||
),
|
||||
'Script',
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
// Give the notecard to our owner
|
||||
await this.bot.clientCommands.comms.giveInventory(this.masterAvatar, exampleNotecard);
|
||||
|
||||
|
||||
@@ -618,6 +618,7 @@ export class InventoryFolder
|
||||
break;
|
||||
}
|
||||
case InventoryType.Script:
|
||||
case InventoryType.LSL:
|
||||
{
|
||||
this.agent.currentRegion.caps.capsPostXML('UpdateScriptAgent', {
|
||||
'item_id': new LLSD.UUID(createInventoryMsg.InventoryData[0].ItemID.toString()),
|
||||
@@ -702,6 +703,7 @@ export class InventoryFolder
|
||||
case InventoryType.Notecard:
|
||||
case InventoryType.Gesture:
|
||||
case InventoryType.Script:
|
||||
case InventoryType.LSL:
|
||||
// These types must be created first and then modified
|
||||
this.uploadInventoryItem(type, inventoryType, data, name, description).then((invItemID: UUID) =>
|
||||
{
|
||||
|
||||
@@ -241,6 +241,9 @@ export class InventoryItem
|
||||
case 'snapshot':
|
||||
item.inventoryType = InventoryType.Snapshot;
|
||||
break;
|
||||
case 'LSL':
|
||||
item.inventoryType = InventoryType.LSL;
|
||||
break;
|
||||
case 'attach':
|
||||
item.inventoryType = InventoryType.Attachment;
|
||||
break;
|
||||
|
||||
@@ -174,6 +174,8 @@ export class Utils
|
||||
return 'gesture';
|
||||
case InventoryType.Mesh:
|
||||
return 'mesh';
|
||||
case InventoryType.LSL:
|
||||
return 'LSL';
|
||||
default:
|
||||
console.error('Unknown inventory type: ' + InventoryType[type]);
|
||||
return 'texture';
|
||||
|
||||
Reference in New Issue
Block a user