Paste #14389: schematic build

Date: 2015/03/09 19:58:31 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


schematicbuild: 
  type: world 
  debug: false
  events: 
    on player places i@buildchest:  
    - flag player sb.buildingname:<context.item_in_hand.display>
    - flag server sb.buildinglc:<context.location>
    - flag player sb.buildinglore:<context.item_in_hand.lore>
    - schematic load name:<player.flag[sb.buildingname]> 
    - if <player.location.yaw.simple> == East {
      - schematic rotate name:<player.flag[sb.buildingname]> angle:0
      }
    - if <player.location.yaw.simple> == south {
      - schematic rotate name:<player.flag[sb.buildingname]> angle:90
      }
    - if <player.location.yaw.simple> == west {
      - schematic rotate name:<player.flag[sb.buildingname]> angle:180
      }
    - if <player.location.yaw.simple> == north {
      - schematic rotate name:<player.flag[sb.buildingname]> angle:270
      }    
    - if <schematic[<player.flag[sb.buildingname]>].cuboid[<context.location>].has_region> {             
      - narrate "<&4>You cannot build this here!"  
      - schematic unload name:<player.flag[sb.buildingname]>
      - determine passively cancelled  
      - flag player sb.buildinglore:!
      - flag player sb.buildingname:!
      - flag server sb.buildinglc:!    
      }    
      else {   
      - if <schematic[<player.flag[sb.buildingname]>].cuboid[<context.location>].has_town> {
        - if <schematic[<player.flag[sb.buildingname]>].cuboid[<context.location>].list_towns> == li@<player.town> {
          - flag player sb.buildlocation:<context.location>
          - flag player sb.building:<context.item_in_hand>
          - inventory open d:in@confirmation
          }
          else {
          - narrate "<&4>You cannot build this here!"
          - schematic unload name:<player.flag[sb.buildingname]>
          - determine passively cancelled
          - flag player sb.buildinglore:!
          - flag player sb.buildingname:!
          - flag server sb.buildinglc:!
          }
        }
        else {
        - flag player sb.buildlocation:<context.location>
        - flag player sb.building:<context.item_in_hand>
        - inventory open d:in@confirmation
        }    
      }
    on player clicks in in@confirmation:
    - if <context.item.scriptname||null> == accept {
      - schematic load name:<player.flag[sb.buildingname]>  
      - schematic paste name:<player.flag[sb.buildingname]> <player.flag[sb.buildlocation]> noair  
      - flag player sb.buildresponse:true
      - narrate "<&2>building <player.flag[sb.buildingname]>!"
      - modifyblock <player.flag[sb.buildlocation]> air
      - schematic unload name:<player.flag[sb.buildingname]>
      - flag player sb.buildlocation:!
      - flag player sb.building:!
      - flag player sb.buildingname:!
      - flag server sb.buildinglc:!
      - flag palyer sb.buildinglore:!
      - determine passively cancelled 
      - inventory close
      }
    - if <context.item.scriptname||null> == deny {
      - narrate "<&4>cancelled!"
      - flag player sb.buildresponse:true
      - modifyblock <player.flag[sb.buildlocation]> air
      - !flag player sb.buildlocation:!
      - give <player.name> "<player.flag[sb.building]>[display_name=<player.flag[sb.buildingname]>;lore=<player.flag[sb.buildinglore]>]" qty:1
      - schematic unload name:<player.flag[sb.buildingname]>      
      - flag player sb.building:!
      - flag player sb.buildingname:!
      - flag palyer sb.buildinglore:!
      - flag server sb.buildinglc:!
      - determine passively cancelled
      - inventory close
      }     
    on player closes inventory:
    - if <context.inventory> == in@confirmation {
      - if <player.flag[sb.buildresponse]> == true {
        - flag player sb.buildresponse:false
        }
        else {
        - narrate "<&4>cancelled!"
        - modifyblock <player.flag[sb.buildlocation]> air
        - determine passively cancelled
        - give <player.name> "<player.flag[sb.building]>[display_name=<player.flag[sb.buildingname]>;lore=<player.flag[sb.buildinglore]>]" qty:1
        - schematic unload name:<player.flag[sb.buildingname]>        
        - flag player sb.buildlocation:!
        - flag player sb.building:!
        - flag player sb.buildingname:!
        - flag server sb.buildinglc:!
        - flag player sb.buildinglore:!
        }
      }    
    on player breaks CHEST:
    - if <context.location> == <server.flag[sb.buildinglc]> {
      - narrate "someone is building!"
      - determine cancelled
      }

buildchest:
    type: item
    material: CHEST
    display name: "build"
    lore:
    - Place this to build!

NewBuild: 
   type: command 
   name: buildchest 
   script: 
   - give "i@buildchest[display_name=<context.raw_args>;lore=Place this to build <context.raw_args>]" 

accept:
    type: item
    material: 159,13
    display name: "<&2>Accept"

deny:
    type: item
    material: 159,14
    display name: "<&4>Deny"

confirmation:  
  type: inventory
  inventory: Chest
  title: "Build this here?"
  size: 27
  definitions:
  slots:
    - "[] [] [] [] [] [] [] [] []"
    - "[] [] [i@accept] [] [] [] [i@deny] [] []"
    - "[] [] [] [] [] [] [] [] []"