Paste #2108: Bits and Pieces v2.0012

Date: 2014/02/18 20:17:13 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


InventoryTrading:
  type: world
  constants:
    0: li@1|2|3|4|10|11|12|13|19|20|21|22|28|29|30|31|37|38|39|40|46|47|48|49
    1: li@6|7|8|9|15|16|17|18|24|25|26|27|33|34|35|36|42|43|44|45|51|52|53|54
  events:
    on player right clicks player:
    - if <player.flag[InventoryTrading.Initiating]||false> run local path:Initiate def:<context.entity>
      else if <player.flag[InventoryTrading.InitAccepting]||false> run local path:Initiated def:<context.entity>
      else if <player.flag[InventoryTrading.InitPending]||false> flag "InventoryTrading.InitAccepting" duration:2s
      else flag "InventoryTrading.Initiating" duration:2s
    on player clicks in inventory:
    - if <context.inventory.title> == "<&b>Player Trading GUI" {
      - if <context.item.display_name> == "<green>Confirm" inventory open d:in@InventoryTradingInvConfirm
        else if <context.item.display_name> == "<red>Decline" inventory open d:in@InventoryTradingInvDecline
        else if <context.inventory.contains[<context.item>]> && !<script.cons[constants.<player.flag[InventoryTrading.CurrSide]>].as_list.contains[<context.slot>]> determine cancelled
      }
      else if <context.inventory.title> == "<green>Accept Trade Offer" {
        - if <context.item.display_name> == "<green>Exit" run local path:ConfirmConfirm
          else if <context.item_display_name> == "<red>Decline" run local path:ExitDecline
      }
      else if <context.inventory.title> == "<red>Decline Trade Offer" {
        - if <context.item.display_name> == "<green>Exit" run local path:DeclineConfirm
          else if <context.item_display_name> == "<red>Decline" run local path:ExitDecline
      }
  Initiate:
    - if <def[1].flag[InventoryTrading.InitPending]||false> narrate target:%1% "<&b><player.name> <yellow>has sent you a trade request. Right-click them twice to accept."
    - flag player:%1% "InventoryTrading.InitPending"
  Initiated:
    - note in@InventoryTradingInvMain as:Trade_%1%_<player>
    - flag player "InventoryTrading.WithPlayer:%1%"
    - flag player "InventoryTrading.CurrSide:1"
    - inventory open d:in@Trade_%1%_<player>
    - flag player:%1% "InventoryTrading.CurrSide:0"
    - define old_player <player>
    - flag player:%1% "InventoryTrading.WithPlayer:%old_player%"
    - inventory player:%1% open d:in@Trade_<player>_%old_player%
  ConfirmConfirm:
    - inventory close "Test<&co> Trade confirmed."
  DeclineConfirm:
    - inventory close "Test<&co> Trade declined."
  ExitDecline:
    - if <player.flag[InventoryTrading.CurrSide]> == 0 inventory open :in@Trade_<player.flag[InventoryTrading.WithPlayer]>_<player>
      else if <player.flag[InventoryTrading.CurrSide]> == 1 inventory open :in@Trade_<player>_<player.flag[InventoryTrading.WithPlayer]>

InventoryTradingInvMain:
  type: inventory
  size: 54
  title: <&b>Player Trading GUI
  definitions:
    accept: i@lime_wool[display_name=<green>Confirm;lore=You are done adding items.]
    decline: i@red_wool[display_name=<red>Decline;lore=You want to cancel the trade.]
    divider: i@rails
  slots:
  - "[] [] [] [] [divider] [] [] [] []"
  - "[] [] [] [] [divider] [] [] [] []"
  - "[] [] [] [] [divider] [] [] [] []"
  - "[] [] [] [] [divider] [] [] [] []"
  - "[] [] [] [] [divider] [] [] [] []"
  - "[] [] [] [accept] [divider] [decline] [] [] []"

InventoryTradingInvConfirm:
  type: inventory
  size: 9
  title: <green>Accept Trade Offer
  definitions:
    accept: i@lime_wool[display_name=<green>Exit;lore=You are REALLY done adding items.]
    decline: i@red_wool[display_name=<red>Decline;lore=You're not quite done adding items.]
  slots:
  - "[] [] [] [accept] [] [decline] [] [] []"


InventoryTradingInvConfirm:
  type: inventory
  size: 9
  title: <red>Decline Trade Offer
  definitions:
    accept: i@lime_wool[display_name=<green>Exit;lore=You REALLY want to cancel this trade.]
    decline: i@red_wool[display_name=<red>Decline;lore=You don't want to cancel the trade.]
  slots:
  - "[] [] [] [accept] [] [decline] [] [] []"