Paste #4546: Minecart Removal

Date: 2014/05/25 08:35:51 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#
# Minecart disposal
#

MinecartTrash:
  type: world
  debug: true

  # Local script for handling cart removal
  # (So we don't have a bunch of duplicated scripting)
  cart_remover:
  - flag <player> no_exit duration:1s
  - remove <context.vehicle>
  - queue clear

  events:

    # 
    # Handle minecart collisions with cactus
    # 

    on minecart collides with cactus:

    # Make sure there's a passenger
    - if <context.vehicle.get_passenger> == null inject locally cart_remover

    # Check regions, do stuff
    - if <context.vehicle.location.in_region[prisona]> {
        - execute as_server "manuadd <context.vehicle.get_passenger.name> A Prison"
        - run rankA as:<context.vehicle.get_passenger>

        } else if <context.vehicle.location.in_region[prisonh]> {
        - execute as_server "manuadd <context.vehicle.get_passenger.name> H Prison"
        - run rankH as:<context.vehicle.get_passenger>

        }

    # No matter what at this point, remove the cart
    - inject locally cart_remover


    # 
    # Handle minecart exit for players
    # 

    on player exits minecart:

    # If collision with cactus just happened, no need to continue
    - if <player.is_flagged[no_exit]> queue clear


    - if <context.vehicle.location.in_region[prison|starttoa]> {
      - execute as_player "warp prison"

      } else if <context.vehicle.location.in_region[prisona]> {
      - execute as_server "manuadd <context.vehicle.get_passenger.name> A Prison"
      - execute as_player "warp a"

      } else if <context.vehicle.location.in_region[gtoh]> {
          - execute as_player "warp gtoh"
      }

    # Remove the cart
    - inject locally cart_remover



"rankA":
  type: task
  debug: true
  script:
    - execute as_player "warp a"


"rankH":
  type: task
  debug: true
  script:
    - execute as_player "warp h"