Paste #39: Replacer

Date: 2013/10/19 20:36:51 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# Replacer tool

Replacer tool:
    type: world

    events:
        on player right clicks with i@block replacer:
        - if !<player.is_op> determine fulfilled
        - if <player.is_sneaking> {
            - narrate "Block replacer is currently set to '<player.flag[block_replacer_material] || m@stone>'."
          } else {
            - flag <player> block_replacer_material:<player.location.cursor_on.block.material>
            - narrate "Block replacer material set to '<player.flag[block_replacer_material]>'."
          }
        - determine cancelled

        on player left clicks with i@block replacer:
        - if !<player.is_op> determine fulfilled
        - if <player.is_sneaking> {
            - modifyblock <player.flag[block_replacer_undo_location]> material:<player.flag[block_replacer_undo_material]>
            - flag <player> block_replacer_undo_material[<player.flag[block_replacer_undo_material].size>]:<-
            - flag <player> block_replacer_undo_location[<player.flag[block_replacer_undo_location].size>]:<-
            - narrate 'Undone. <player.flag[block_replacer_undo_location].size> undos left.' 

          } else {
            - flag <player> block_replacer_undo_material:->:<player.location.cursor_on.block.material>
            - flag <player> block_replacer_undo_location:->:<player.location.cursor_on.simple>
            - modifyblock '<player.location.cursor_on>' 'material:<player.flag[block_replacer_material] || m@stone>'
            - if <player.flag[block_replacer_undo_material].size> > 30 {
                - flag <player> block_replacer_undo_material[1]:<-
                - flag <player> block_replacer_undo_location[1]:<-
              }
          }

        - determine cancelled

        on replacer command:
        - if <c.raw_args> == 'reset' {
            - flag <player> block_replacer_undo_material:!
            - flag <player> block_replacer_undo_location:!
            - flag <player> block_replacer_material:! 
            - narrate 'Reset flags for replacer tool.'
          } else drop 'i@block replacer' <player.location>

        - determine fulfilled


Block Replacer:
    type: item

    material: gold_spade
    display name: <gold>Block Replacer
    lore:
    - <light_purple>Easily replace blocks!
    - <white>-------------------------------
    - <yellow>right click a block to set the material
    - <yellow>shift-right click to see the current material
    - <yellow>left click a block to replace
    - <yellow>shift-left click to undo the replacement