Paste #119992: Unnamed Denizen Script Paste

Date: 2024/02/05 14:31:39 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


equip_hooks:
    type: world
    debug: false
    data:
        40: HELMET
        39: CHESTPLATE
        38: LEGGINGS
        37: BOOTS
    events:
        on block dispenses item:
            - define item <context.item>
            - define loc <context.location.add[<context.location.block_facing>]>
            - define players <[loc].find_players_within[2].filter[location.distance[<context.location.center>].is_less_than_or_equal_to[2.4]]>
            - if <[players].any>:
                - definemap context:
                    source: DISPENSER
                    entity: <[players].lowest[location.distance[<context.location.center>]]>
                    status: equip
                    item: <[item]>
                - customevent id:equipment_change context:<[context]>
        # -------------------------------------------------- #
        # context.source - Source in which triggered the event. (RIGHT_CLICK, INVENTORY_CLICK, DISPENSER)
        # context.entity - The entity that had their equipment changed.
        # context.status - The type of equipping being done. Equip/Unequip/Swap
        # context.item - The item being equipped or unequipped
        # context.swapped - The item being swapped out during a swap status.
        # -------------------------------------------------- #
        on custom event id:equipment_change:
            - if <context.entity.is_player>:
                - define S "<&e><context.item.proc[items_display].strip_color><&7> equipped."
                - define S "<&e><context.item.proc[items_display].strip_color><&7> unequipped." if:<context.status.equals[unequip]>
                - narrate <[S]> format:chat_format_debug targets:<context.entity>