Paste #105634: a

Date: 2023/01/22 04:56:55 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 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]>:
            - define nbt <[inv].slot[21].raw_nbt>
            - define lore <[inv].slot[21].lore>
            - define lore_loc <[lore].find_partial[physical damage]>
            - define new_stat_value <[phy_dmg2].after[double:].add[99.0]>
            - define new_lore_value <[lore].insert[  ؏ » Physical Damage: +<[new_stat_value]>%].at[<[lore_loc]>]>

            - narrate "indice : <[lore].find_partial[physical damage]>"
            #- narrate "old lore : <[lore].get[<[lore_loc]>]>"
            #- narrate "new lore : <[new_lore_value]>"
            - inventory adjust destination:<[inv]> slot:21 raw_nbt:<[nbt].with[MMOITEMS_PHYSICAL_DAMAGE].as[double:<[new_stat_value]>]>
            - inventory adjust destination:<[inv]> slot:21 lore: <[new_lore_value]>
        - else:
            - narrate "no physical damage"