Paste #105578: a

Date: 2023/01/20 23:53:10 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


upgrader_inventory_logic_world:
    type: world
    debug: true
    events:

        on player clicks in Upgrader_GUI:
        - define inv <context.inventory>
        - define click_inv <context.clicked_inventory>
        - define slot <context.slot>
        - define sh_click <context.is_shift_click>

        - if <[click_inv]> == <[inv]>:
            - if <[slot]> == 21 or <[slot]> == 22 or <[slot]> == 23:
                #- announce "click correct slot"
                - determine cancelled:false
            - else:
                - if <[slot]> == 25:
                    #- narrate "<&[base]>upgrade button clicked!"
                    - run locally path:upgrader_process_logic def:<[inv]>
                    - determine cancelled
                - else:
                   # - narrate "click cancelled"
                    - determine cancelled
        - if <[click_inv]> != <[inv]> && <[sh_click]>:
            #- narrate "shift cancelled"
            - determine cancelled

        on player drags in Upgrader_GUI:
        - define inv <context.inventory>
        - define click_inv <context.clicked_inventory>

        - if <[click_inv]> == <[inv]>:
            - announce "drag cancelled"
            - determine cancelled

        on player closes Upgrader_GUI:
        - drop <context.inventory.slot[21]>
        - drop <context.inventory.slot[22]>
        - drop <context.inventory.slot[23]>

    upgrader_process_logic:
        - define inv <[1]>
        - define nbt <[inv].slot[21].raw_nbt>
        - define phy_dmg <[inv].slot[21].raw_nbt.get[MMOITEMS_PHYSICAL_DAMAGE].after[double:]>
        - define phy_dmg2 <[inv].slot[21].raw_nbt.get[MMOITEMS_PHYSICAL_DAMAGE]>
        - if <[inv].slot[21].raw_nbt.contains[MMOITEMS_PHYSICAL_DAMAGE]>:
            - narrate "old physical damage = <[phy_dmg]>"
            - define new_value <[phy_dmg2].after[double:].add[2.0]>
            - narrate "new physical damage = <[new_value]>"
            - inventory adjust <[inv].slot[21]> raw_nbt:<[nbt].with[MMOITEMS_PHYSICAL_DAMAGE].as[double:2.3]>
            - narrate "after adjust = <[inv].slot[21].raw_nbt.get[MMOITEMS_PHYSICAL_DAMAGE]>"
        - else:
            - narrate "no physical damage"