Paste #105657: a

Date: 2023/01/22 13:05:41 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 selecter_tools in Upgrader_GUI_select:
            - inventory open destination:Upgrader_GUI_tools
        on player clicks selecter_weapons in Upgrader_GUI_select:
            - inventory open destination:Upgrader_GUI_weapons
        on player clicks selecter_armor in Upgrader_GUI_select:
            - inventory open destination:Upgrader_GUI_armor

        on player clicks in Upgrader_GUI_tools:
        - define inv <context.inventory>
        - define click_inv <context.clicked_inventory>
        - define slot <context.slot>
        - define slot_mat1 <context.inventory.slot[14]>
        - define sh_click <context.is_shift_click>

        - if <[click_inv]> == <[inv]>:
            - if <[slot]> == 41 or <[slot]> == 14:
                - determine cancelled:false
            - else:
                - if <[slot]> == 1:
                    - if <[slot_mat1].raw_nbt.get[MMOITEMS_ITEM_ID]> == string:IMPURE_RUBY:
                        - run locally path:upgrader_process_logic def:<[inv]>
                        - take item:paper from:<[inv]> slot:21
                        - determine cancelled
                    - else:
                        - narrate "upgrade materials needed"
                        - determine cancelled
                - else:
                    - determine cancelled
        - if <[click_inv]> != <[inv]> && <[sh_click]>:
            - determine cancelled

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

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

        on player closes Upgrader_GUI_tools:
        - drop <context.inventory.slot[14]>
        - drop <context.inventory.slot[41]>

        on player clicks in Upgrader_GUI_weapons:
        - define inv <context.inventory>
        - define click_inv <context.clicked_inventory>
        - define slot <context.slot>
        - define slot_mat1 <context.inventory.slot[14]>
        - define sh_click <context.is_shift_click>

        - if <[click_inv]> == <[inv]>:
            - if <[slot]> == 41 or <[slot]> == 14:
                - determine cancelled:false
            - else:
                - if <[slot]> == 1:
                    - if <[slot_mat1].raw_nbt.get[MMOITEMS_ITEM_ID]> == string:IMPURE_RUBY:
                        - run locally path:max_durability_logic def:<[inv]>
                        - take item:paper from:<[inv]> slot:21
                        - determine cancelled
                    - else:
                        - narrate "upgrade materials needed"
                        - determine cancelled
                - else:
                    - determine cancelled
        - if <[click_inv]> != <[inv]> && <[sh_click]>:
            - determine cancelled

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

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

        on player closes Upgrader_GUI_weapons:
        - drop <context.inventory.slot[14]>
        - drop <context.inventory.slot[41]>


        on player clicks in Upgrader_GUI_armor:
        - define inv <context.inventory>
        - define click_inv <context.clicked_inventory>
        - define slot <context.slot>
        - define slot_mat1 <context.inventory.slot[14]>
        - define sh_click <context.is_shift_click>

        - if <[click_inv]> == <[inv]>:
            - if <[slot]> == 41 or <[slot]> == 14:
                - determine cancelled:false
            - else:
                - if <[slot]> == 1:
                    - if <[slot_mat1].raw_nbt.get[MMOITEMS_ITEM_ID]> == string:IMPURE_RUBY:
                        - run locally path:upgrader_process_logic def:<[inv]>
                        - take item:paper from:<[inv]> slot:21
                        - determine cancelled
                    - else:
                        - narrate "upgrade materials needed"
                        - determine cancelled
                - else:
                    - determine cancelled
        - if <[click_inv]> != <[inv]> && <[sh_click]>:
            - determine cancelled

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

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

        on player closes Upgrader_GUI_armor:
        - drop <context.inventory.slot[14]>
        - drop <context.inventory.slot[41]>


    upgrader_process_logic:
        - define inv <[1]>

        - if <[inv].slot[41].raw_nbt.contains[MMOITEMS_PHYSICAL_DAMAGE]>:
            - define nbt <[inv].slot[41].raw_nbt>
            - define phy_dmg <[inv].slot[41].raw_nbt.get[MMOITEMS_PHYSICAL_DAMAGE].after[double:]>
            - define lore <[inv].slot[41].lore>
            - define lore_loc <[lore].find_partial[physical damage]>
            - define new_stat_value <[phy_dmg].add[99.0]>
            - define new_lore_value <[lore].set[  <&color[f]>؏ <&color[8]>» <&color[f]>Physical Damage: <&color[3]><&color[l]>+<[new_stat_value]>%].at[<[lore_loc]>]>

            - inventory adjust destination:<[inv]> slot:41 raw_nbt:<[nbt].with[MMOITEMS_PHYSICAL_DAMAGE].as[double:<[new_stat_value]>]>
            - inventory adjust destination:<[inv]> slot:41 "lore:<[new_lore_value]>"
        - else:
            - narrate "no physical damage"



    max_durability_logic:
        - define inv <[1]>

        - if <[inv].slot[41].raw_nbt.contains[MMOITEMS_MAX_DURABILITY]>:
            - define nbt <[inv].slot[41].raw_nbt>
            - define lore <[inv].slot[41].lore>
            - define lore_loc <[lore].find_partial[durability]>
            - define max_durability <[inv].slot[41].raw_nbt.get[MMOITEMS_MAX_DURABILITY].after[int:]>
            - define new_max_dur <[max_durability].add[100]>
            - define new_lore_value <[lore].set[  <&color[f]>؃ <&color[8]>» <&color[f]>Durability: <&color[a]><&color[l]><[new_max_dur]> / <[new_max_dur]>].at[<[lore_loc]>]>

            - inventory adjust destination:<[inv]> slot:41 raw_nbt:<[nbt].with[MMOITEMS_MAX_DURABILITY].as[int:<[new_max_dur]>]>
            - inventory adjust destination:<[inv]> slot:41 "lore:<[new_lore_value]>"