#Durability

1 messages · Page 1 of 1 (latest)

bright lotusBOT
#
Debug Result

There is an error in this [code](#1242131491203584071 message):

main.js:72:25 - error TS2365: Operator '>=' cannot be applied to types 'number' and 'ItemDurabilityComponent'.

72                     if (blocksMined >= durabilityComponent) {
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

celest ember
#

ahh

celest ember
#

I can't seem to fix it

knotty kernel
#

durabilityComponent

#

is an object

#

and u need a string

#

to compare it

celest ember
#

I still can't figure this out. I did what Sam said to do

#

but that wouldn't work

grave crypt
#

👌

bright lotusBOT
grave crypt
#

it's not a link

#

lmao

#

damage: number

celest ember
#

what?

grave crypt
#

to get durability, use damage property

#

which is number

celest ember
#

yes

#

but that isn't working

unique fox
# celest ember yes

Equippable

const equipment = player.getComponent('equippable');
const mainHand = equipment.getItem("Mainhand");
const durability = mainHand.getComponent('durability')

// set
mainHand.setDynamicProperty('test', true);

// set back to the inventory
equipment.setEquipment("Mainhand", mainHand);```

# Inventory

```js
const inventory = player.getComponent('inventory').container;
const selectedItem = inventory.getItem(player.selectedSlot);
const durability = selectedItem.getComponent('durability')

// set
selectedItem.setDynamicProperty('test', true);

// set back to the inventory
inventory.setItem(player.selectedSlot, selectedItem);```
celest ember
#

thank you