Paste #40144: Untitled Paste

Date: 2017/02/21 19:41:17 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# - run AreaMover_Task_Move world:<context.location.world>|name:<def[name]>

AreaMover_Task_Move:
  type: task
  debug: minimal
  script:
    - yaml 'areamover_queues' set running.<def[name]> '<queue.id>'
    - define direction <yaml[areamover_<def[world]>].read[areas.<def[name]>.direction]>
    - define cuboid <server.cuboid_wrapping[<yaml[areamover_<def[world]>].read[areas.<def[name]>.min]>|<yaml[areamover_<def[world]>].read[areas.<def[name]>.max]>]>
#    - define speed <number[21].subtract[<yaml[areamover_<def[world]>].read[areas.<def[name]>.speed]>].multiply[0.05]>]>
    - if <def[direction]> == north:
      - define dlen <integer[<def[cuboid].max.z.sub[<def[cuboid].min.z>].add[1]>]>
      - define offset 0,0,-1
      - define idir south
    - else if <def[direction]> == south:
      - define dlen <integer[<def[cuboid].max.z.sub[<def[cuboid].min.z>].add[1]>]>
      - define offset 0,0,1
      - define idir north
    - else if <def[direction]> == east:
      - define dlen <integer[<def[cuboid].max.x.sub[<def[cuboid].min.x>].add[1]>]>
      - define offset 1,0,0
      - define idir west
    - else if <def[direction]> == west:
      - define dlen <integer[<def[cuboid].max.x.sub[<def[cuboid].min.x>].add[1]>]>
      - define offset -1,0,0
      - define idir east
    - else if <def[direction]> == up:
      - define dlen <integer[<def[cuboid].max.y.sub[<def[cuboid].min.y>].add[1]>]>
      - define offset 0,1,0
      - define idir down
    - else if <def[direction]> == down:
      - define dlen <integer[<def[cuboid].max.y.sub[<def[cuboid].min.y>].add[1]>]>
      - define offset 0,-1,0
      - define idir up
    - else:
      - define path trigger.failed
      - define source player
      - inject AreaMover_Task_Messages
      - yaml 'areamover_queues' remove running.<def[name]>
      - stop
    # Build list of materials
    - define mats <list[]>
    - define data <list[]>
    - foreach start <def[cuboid].block_locations> --save block:
      - addto mats list <def[block].block_type>
      - addto data list <def[block].data>
#      - setblock <def[block]> minecraft:air
    # Move area in a direction
    - repeat <def[dlen]>:
      - foreach start <def[cuboid].block_locations> --save block:
        - setblock <def[block]> minecraft:air false
      - define cuboid <server.cuboid_wrapping[<def[cuboid].min.add[<def[offset]>]>|<def[cuboid].max.add[<def[offset]>]>]>
      - foreach start <def[cuboid].block_locations> --save block:
        - setblock <def[block]> <def[mats].get[<def[foreach_index]>]> false
        - editblock <def[block]> <def[data].get[<def[foreach_index]>]>
      - wait 0.5s
    - yaml areamover_<[world]> set 'areas.<[name]>.direction' '<[idir]>'
    - yaml areamover_<[world]> set 'areas.<[name]>.min' '<[cuboid].min>'
    - yaml areamover_<[world]> set 'areas.<[name]>.max' '<[cuboid].max>'
    - yaml areamover_<[world]> save '../../AreaMover/<[world]>'
    - yaml 'areamover_queues' remove running.<def[name]>