Paste #31933: vendor

Date: 2016/03/24 19:24:47 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Shops_World:
  type: world
  debug: false
  events:
    on player clicks in inventory:
     else if <context.inventory.title.contains_text[Sell]> {
     - determine cancelled passively
     - if <context.raw_slot> > <context.inventory.size> {
       - queue clear
       }
     - if <context.item.simple> == i@redstone {
       - inventory open d:in@<context.item.lore.as_list.get[3].strip_color>
       - queue clear
       }
     - if <context.item> != i@air {
       - define payment <proc[Shop_Sell].context[<context.item.simple>|<context.item.quantity>].get[2]>
       - if <player.inventory.contains.material[<context.item.material>].quantity[<context.item.quantity>]> {
       # - take <player.inventory.list_contents.full.filter[material.is[==].to[grass]]>
       # - if <player.inventory.quantity[<context.item.simple>]> >= <context.item.quantity> {
         - foreach <player.inventory.list_contents> {
           - if <def[value].material.is[=].to[<context.item.material>]> && <def[value].scriptname||null> == null {
             # - if <player.inventory.list_contents.count[<def[value]>]  THIS IS WHERE I NEED TO CHECK IF ITEM IS EQUIPPED
             - take <def[value].full> qty:<context.item.quantity> from:<player.inventory>
             - give money qty:<def[payment].as_decimal>
             - if <context.item.quantity> > 1 {
               - narrate "You sold <context.item.quantity> <context.item.formatted> for <&a>$<def[payment].as_money><&f>!" targets:<player>
               }
               else {
               - narrate "You sold <context.item.formatted> for <&a>$<def[payment].as_money><&f>!" targets:<player>
               }
             - narrate "Balance: <&a>$<player.money>"
             - queue clear
             }
           }
         - narrate "<&c>You don't have that item to sell!"
         - queue clear
         }
         else {
         - narrate "<&c>You don't have that item to sell!"
         - queue clear
         }
       }
     }