Paste #28087: Berufeng's Bookshelves WIP

Date: 2016/01/08 21:06:19 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Bookshelves:
    type: world
    Whitelist:
    - map
    - empty_map
    - book
    - book_and_quill
    - paper
    - written_book
    events:
        on player right clicks bookshelf:
            - determine passively CANCELLED
            - define shelflocation <context.location.simple>
            - define userlist <context.location.find.players.within[5].filter[open_inventory.is[==].to[in@shelf_<def[shelflocation]>]]>
            - if <def[userlist].size> > 0 {
                - narrate "<&4><def[userlist].get[1].name> is already using that!"
                - queue clear
            }
            - if <server.list_notables[inventories].parse[notable_name].contains[shelf_<def[shelflocation]>].not> {
                - note "in@generic[size=27;title=Book Shelf]" as:shelf_<def[shelflocation]>
            }
            - inventory open d:in@shelf_<def[shelflocation]>
        on player breaks bookshelf:
            - define brokenshelf shelf_<context.location.simple>
            - if <server.list_notables[inventories].parse[notable_name].contains[<def[brokenshelf]>].not||true> {
                - determine i@bookshelf
                - queue clear
            }
            - if <def[brokenshelf].as_inventory.list_contents> > 0 {
                - determine <def[brokenshelf].as_inventory.list_contents.full.include[i@bookshelf]>
            } else {
                - determine i@bookshelf
            }
        on player clicks in inventory:
            - if <player.gamemode.is[==].to[CREATIVE]> queue clear
            - if <context.inventory.notable_name.starts_with[shelf_].not||true> queue clear
            - if <context.raw_slot.is[MORE].than[27]> queue clear
            - if <script.yaml_key[Whitelist].contains[<c.item.material.name>].not> {
                - narrate "<&4>You can't place that in a bookshelf!"
                - determine CANCELLED
            }