Paste #12309: Pet Shop

Date: 2014/12/28 16:18:15 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


PetShopPuppyAssignment:
  type: assignment
  debug: false
  actions:
    on assignment:
    - trigger "name:click" "state:true"
  interact scripts:
  - 10 PetShopPuppyInteract

PetShopPuppyInteract:
  type: interact
  debug: false
  steps:
    1:
      click trigger:
        script:
        - inventory open "d:in@PetShopPuppyInventory"

PetShopKittenAssignment:
  type: assignment
  debug: false
  actions:
    on assignment:
    - trigger "name:click" "state:true"
  interact scripts:
  - 10 PetShopKittenInteract

PetShopKittenInteract:
  type: interact
  debug: false
  steps:
    1:
      click trigger:
        script:
        - inventory open "d:in@PetShopKittenInventory"

PetShopEvents:
  type: world
  debug: false
  events:
    on player clicks in in@PetShopPuppyInventory:
    - determine passively cancelled
    - if <context.raw_slot> >= 1 && <context.raw_slot> <= 18 && <context.item||i@air> != i@air {
      - define loreline <context.item.lore.size||0>
      - if %loreline% == 0 {
        - narrate "That item randomly doesn't have a fking price!"
        }
      - define price "<context.item.lore.get[%loreline%].after[Price<&co> $]>"
      - if <player.flag[morpheconomy.money].as_money||0.00> >= %price% {
        - flag global "PetShop.Confirm.Title:Dog w/<context.item.display_name>"
        - flag global "PetShop.Confirm.Size:18"
        - flag global "PetShop.Confirm.Price:%price%"
        - flag global "PetShop.Confirm.ExtraData:<context.item.material.name.replace[_wool]>"
        - inventory open "d:in@PetShopConfirmationWindow"
        }
        else {
        - narrate "<red>You don't have enough money for that!"
        }
      }
    on player clicks in in@PetShopKittenInventory:
    - determine passively cancelled
    - if <context.raw_slot> >= 1 && <context.raw_slot> <= 9 && <context.item||i@air> != i@air {
      - define loreline <context.item.lore.size||0>
      - if %loreline% == 0 {
        - narrate "That item randomly doesn't have a fking price!"
        }
      - define price "<context.item.lore.get[%loreline%].after[Price<&co> $]>"
      - if <player.flag[morpheconomy.money].as_money||0.00> >= %price% {
        - flag global "PetShop.Confirm.Title:Kitten (<context.item.display_name>)"
        - flag global "PetShop.Confirm.Size:9"
        - flag global "PetShop.Confirm.Price:%price%"
        - flag global "PetShop.Confirm.ExtraData:<context.item.display_name.to_lowercase.replace[ ].with[_]>"
        - inventory open "d:in@PetShopConfirmationWindow"
        }
        else {
        - narrate "<red>You don't have enough money for that!"
        }
      }
    on player clicks in in@PetShopConfirmationWindow:
    - determine passively cancelled
    - if <context.raw_slot> >= 1 && <context.raw_slot> <= <context.inventory.size> && <context.item||i@air> != i@air {
      - if <context.item.display_name> == "<red>No" {
        - inventory open "d:in@PetShopPuppyInventory"
        - determine cancelled
        }
      - define price "<context.item.lore.get[2].after[Price<&co> $]>"
      - if <player.flag[morpheconomy.money].as_money||0.00> >= %price% {
        - define title <context.inventory.title>
        - if "<def[title].starts_with[Dog w/]>" {
          - spawn "e@wolf[age=baby;color=<context.item.lore.get[1]>;tame=true|<player>;sitting=true]" <player.location>
          }
          else if "<def[title].starts_with[Kitten (]>" {
          - spawn "e@ocelot[age=baby;color=<context.item.lore.get[1]>;tame=true|<player>;sitting=true]" <player.location>
          }
        - flag "morpheconomy.money:--:%price%"
        - inventory close
        }
        else {
        - narrate "<red>You don't have enough money for that!"
        }
      }

PetShopPuppyInventory:
  type: inventory
  debug: false
  size: 18
  title: <dark_green>Choose your collar color<&co>
  definitions:
    red: i@red_wool[display_name=<red>Red Collar;lore=Price<&co> $10]
    orange: i@orange_wool[display_name=<gold>Orange Collar;lore=Price<&co> $10]
    yellow: i@yellow_wool[display_name=<yellow>Yellow Collar;lore=Price<&co> $10]
    green: i@green_wool[display_name=<dark_green>Green Collar;lore=Price<&co> $10]
    blue: i@blue_wool[display_name=<dark_blue>Blue Collar;lore=Price<&co> $10]
    light_blue: i@light_blue_wool[display_name=<blue>Light Blue Collar;lore=Price<&co> $10]
    magenta: i@magenta_wool[display_name=<light_purple>Magenta Collar;lore=Price<&co> $10]
    pink: i@pink_wool[display_name=<light_purple>Pink Collar;lore=Price<&co> $10]
    white: i@white_wool[display_name=<white>White Collar;lore=Price<&co> $10]
    light_gray: i@light_gray_wool[display_name=<gray>Light Gray Collar;lore=Price<&co> $10]
    black: i@black_wool[display_name=<black>Black Collar;lore=Price<&co> $10]
    brown: i@brown_wool[display_name=<dark_red>Brown Collar;lore=Price<&co> $10]
    cyan: i@cyan_wool[display_name=<dark_aqua>Cyan Collar;lore=Price<&co> $10]
    purple: i@purple_wool[display_name=<dark_purple>Purple Collar;lore=Price<&co> $10]
    gray: i@gray_wool[display_name=<dark_gray>Gray Collar;lore=Price<&co> $10]
    lime: i@lime_wool[display_name=<green>Lime Collar;lore=Price<&co> $10]
  slots:
  - "[red] [orange] [yellow] [green] [blue] [light_blue] [magenta] [pink] []"
  - "[white] [light_gray] [black] [brown] [cyan] [purple] [gray] [lime] []"

PetShopKittenInventory:
  type: inventory
  debug: false
  size: 9
  title: <dark_green>Choose your kitten type<&co>
  definitions:
    black: i@black_wool[display_name=Black Cat;lore=Price<&co> $10]
    red: i@orange_wool[display_name=Red Cat;lore=Price<&co> $10]
    siamese: i@light_gray_wool[display_name=Siamese Cat;lore=Price<&co> $10]
    wild: i@yellow_wool[display_name=Wild Ocelot;lore=Price<&co> $10]
  slots:
  - "[black] [red] [siamese] [wild] [] [] [] []"

PetShopConfirmationWindow:
  type: inventory
  debug: false
  size: <server.flag[PetShop.Confirm.Size]>
  title: <server.flag[PetShop.Confirm.Title]>
  definitions:
    accept: i@green_wool[display_name=<green>Yes;lore=<server.flag[PetShop.Confirm.ExtraData]>|Price<&co> <&ds><server.flag[PetShop.Confirm.Price]>]
    deny: i@red_wool[display_name=<red>No]
  slots:
  - "[] [] [] [] [] [] [] <tern[<server.flag[PetShop.Confirm.Size].is[==].to[9]>]:[accept] [deny]||[] [accept]>"
  - "<tern[<server.flag[PetShop.Confirm.Size].is[==].to[9]>]:||[] [] [] [] [] [] [] [] [deny]>"