|
| 1 | +""" |
| 2 | +Demonstrates item creation as well as bodypart / clothing upload |
| 3 | +""" |
| 4 | + |
| 5 | +from hippolyzer.lib.base.datatypes import UUID |
| 6 | +from hippolyzer.lib.base.templates import WearableType, Permissions |
| 7 | +from hippolyzer.lib.base.wearables import Wearable, VISUAL_PARAMS |
| 8 | +from hippolyzer.lib.proxy.addon_utils import BaseAddon |
| 9 | +from hippolyzer.lib.proxy.commands import handle_command |
| 10 | +from hippolyzer.lib.proxy.region import ProxiedRegion |
| 11 | +from hippolyzer.lib.proxy.sessions import Session |
| 12 | + |
| 13 | + |
| 14 | +class ShapeCreatorAddon(BaseAddon): |
| 15 | + @handle_command() |
| 16 | + async def create_shape(self, session: Session, region: ProxiedRegion): |
| 17 | + """Make a shape with pre-set parameters and place it in the body parts folder""" |
| 18 | + |
| 19 | + wearable = Wearable.make_default(WearableType.SHAPE) |
| 20 | + # Max out the jaw jut param |
| 21 | + jaw_param = VISUAL_PARAMS.by_name("Jaw Jut") |
| 22 | + wearable.parameters[jaw_param.id] = jaw_param.value_max |
| 23 | + wearable.name = "Cool Shape" |
| 24 | + |
| 25 | + # A unique transaction ID is needed to tie the item creation to the following asset upload. |
| 26 | + transaction_id = UUID.random() |
| 27 | + item = await session.inventory.create_item( |
| 28 | + UUID.ZERO, # This will place it in the default folder for the type |
| 29 | + name=wearable.name, |
| 30 | + type=wearable.wearable_type.asset_type, |
| 31 | + inv_type=wearable.wearable_type.asset_type.inventory_type, |
| 32 | + wearable_type=wearable.wearable_type, |
| 33 | + next_mask=Permissions.MOVE | Permissions.MODIFY | Permissions.COPY | Permissions.TRANSFER, |
| 34 | + transaction_id=transaction_id, |
| 35 | + ) |
| 36 | + print(f"Created {item!r}") |
| 37 | + await region.xfer_manager.upload_asset( |
| 38 | + wearable.wearable_type.asset_type, |
| 39 | + wearable.to_str(), |
| 40 | + transaction_id=transaction_id, |
| 41 | + ) |
| 42 | + |
| 43 | + |
| 44 | +addons = [ShapeCreatorAddon()] |
0 commit comments