Paste #50552: Untitled Paste

Date: 2018/11/05 03:18:21 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Sticker:
    type: item
    debug: false
    material: paper
    display name: <gray>Sticker
    lore:
    - <&f>Right click <&6><&l><&gt><&r><&f> to reveal the sticker

Sticker_world:
    type: world
    debug: true
#----------------------------------------------------------------------------#
#                                                                            #
#                                  CONFIG                                    #
#                                                                            #
#----------------------------------------------------------------------------#
    config:
        colors:
        # f = white; b = aqua; d = light purple
        # - "<&f>"
        - "<&b>"
        # - "<&d>"
        lore:
        - "<def[player]> thinks this is a game"
#----------------------------------------------------------------------------#
#                                                                            #
#                                  SCRIPT                                    #
#                                                                            #
#----------------------------------------------------------------------------#   
    events:
        on player right clicks with Sticker:
#----------------------------------------------------------------------------#
#                           CLICK WITH EMPTY CARD                            #
#----------------------------------------------------------------------------#    
        - wait 1t
        # if you have a stack of stickers and a full inventory, it will prevent from running
        - if "<context.item.lore.get[1].is[==].to[<parse:<script[sticker].yaml_key[lore].get[1]>>]>" {
            - ^if <player.inventory.empty_slots> == 0 {
                - narrate "<&c>Not enough invemtory space"
                - queue clear
            }
            - ^define slot <player.item_in_hand.slot>
            - wait 1t
            - ^define Sticker <context.item>
            - ^define Player <player.name>
            - ^define color <parse:<script.yaml_key[config.colors].random>>
            - ^define lore <parse:<script.yaml_key[config.lore].random>>
            - ^adjust <def[Sticker]> "lore:<&sp>|%color%%lore%|<gray>------------------------------|<gray>1. <&lb>Right click<&rb> with sticker in hand|<gray>2. <&lb>Right click<&rb> with desired item in hand|<gray>3. Enjoy your personalised item!|<gray>------------------------------|<&4>Warning! <gray>If the chosen item already|<gray>has lore on it, the old lore WILL be|<gray>overwritten by lore from the card!|<dark_gray>Don<&sq>t use on quest items, etc.|<gray>------------------------------|" save:FullSticker
            - ^take <player.item_in_hand> qty:1
            - ^if <def[slot]> != i@air {
                - ^define slot <player.inventory.first_empty>
            }
            - ^give <entry[FullSticker].result> to:<player.inventory> slot:<def[slot]> qty:1
        } else {
#----------------------------------------------------------------------------#
#                           CLICK WITH FULL CARD                             #
#----------------------------------------------------------------------------#
            - flag player StickerTimer:<player.item_in_hand.lore.get[2]> duration:5s
            - title "subtitle:Ready to imbue <player.flag[StickerTimer]><&r> to an item"
        }
#----------------------------------------------------------------------------#
#                             CLICK WITH ITEM                                #
#----------------------------------------------------------------------------#
        on player right clicks with item:
        - ^if !<player.has_flag[StickerTimer]> {
            - queue clear
        }
        - ^if <context.item.scriptname.is[==].to[Sticker]||false> {
            - queue clear
        }
        - ^if <context.item.scriptname.split[_].get[1].is[==].to[UI]||false> {
            - title "subtitle:<&c>You cannot put stickers on unique items"
            - queue clear
        }
        - determine cancelled passively
        - take iteminhand qty:1
        - wait 1t
        - ^define slot <player.item_in_hand.slot>
        - ^define item <context.item>
        - ^define Lore <player.flag[StickerTimer]>
        - ^if <context.item.has_display> {
            - define Name <context.item.display>
        } else {
            - define Name <context.item.formatted>
        }
        - title title:Congratulations! "subtitle:%lore% <&f>applied to %Name%"
        ### OHRANITEV MOREBITNEGA PREJSNJEGA VECVRSTICNEGA LORA, ZAMENJA SAMO 1 VRSTICO ###
        - if <context.item.has_lore> {
            # TOLE JE KODA, KI DODAJA NEOMEJENO STICKERJEV!!!!
            - ^adjust <def[Item]> lore:<context.item.lore.insert[<def[lore]>].at[1]> save:LoreItem
            # TOLE JE KODA, KI ZAMENJA 1. VRSTICO LORA!!!!
            # - ^adjust <def[Item]> lore:<context.item.lore.replace[<context.item.lore.get[1]>].with[<def[lore]>]> save:LoreItem
        } else {
            - ^adjust <def[Item]> lore:%lore% save:LoreItem
        }
        - ^if <def[slot]> != i@air {
                - ^define slot <player.inventory.first_empty>
            }
        - ^give <entry[LoreItem].result> qty:1 slot:<def[slot]>
        - ^take <player.inventory.list_contents.filter[lore.get[2].contains_any[%lore%]].get[1]> qty:1
        - wait 1t
        - flag player StickerTimer:!