Paste #19228: Untitled Paste

Date: 2015/08/11 03:53:26 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# /doorkey   tier            reset
# /doorkey   tier            list
# /doorkey   tier           create                    hideflags
# /doorkey   tier            edit            display|material|lore|recipe        value
# /doorkey   tier            edit                       lore                      [#]          value
# /doorkey   tier            give                      player
# /doorkey   tier           remove

# lore: 1|2|3|4
# Enter as many values as you want. However they must be separated by |
# Optionally specify a lore line and then the value.
# recipe: 1|2|3|4|5|6|7|8|9
# Items are set up as below; make sure to use the correct name. For example: diamond_sword
# Separation works as with lores.
#  - i@1|i@2|i@3
#  - i@4|i@5|i@6
#  - i@7|i@8|i@9
# When creating an item use hideflags to remove the data shown on the item such as damage, splash effect or other. For example:
# /doorkey mykey create hideflags


DoorKeys:
  type: world
  events:
    on player clicks block:
    - if <context.location.material> !contains "door" {
      - queue clear
      }
    - foreach <server.list_flags> {
      - if <fl@%value%.as_list.contains[<context.location.block>]> {
        - goto is_locked
        }
      - if <def[loop_index]> == <server.list_flags.size> {
        - queue clear
        }
      }
    - mark is_locked
    - foreach <server.list_flags> {
      - if <fl@%value%.as_list.contains[<context.location.block>]> {
        - define tier <def[value].after[T]>
        }
      }
    - if !<context.item.display.contains[<def[tier]>]> {
      - narrate "<red>You need to use the tier <def[tier]> key to open this!"
      - determine cancelled
      } else {
      - narrate "<green>You have used the tier <def[tier]> key!"
      }

    on doorkey command:
    - determine fulfilled passively
    - if <player.is_op> || <context.server> {
      - goto pass
      } else {
      - narrate "<red>Must be Operator to use this command!"
      - queue clear
      }
    - mark pass
    - define tier <context.args.get[1]>
    - choose <context.args.get[2]>:
      - case "remove":
        - narrate "<red>Removed <def[tier]> key!"
        - yaml load:/scripts/doorkeys.dscript id:doorkeys
        - yaml set <def[tier]>:! id:doorkeys
        - queue clear
      - case "give":
        - narrate "<green>Giving <def[tier]> key!"
        - give i@<def[tier]> to:<context.args.get[3]||<player>>
        - queue clear
      - case "list":
        - narrate "<green>Tier <def[tier]> door keys are currently at<&co>"
        - narrate "<green><server.flag[doorkeys_t<def[tier]>]>"
        - queue clear
      - case "reset":
        - flag server doorkeys_t<def[tier]>:none
        - narrate "<green>Tier <def[tier]> door keys reset!"
        - queue clear
      - case "create":
        - if !<server.has_file[/scripts/doorkeys.dscript]> {
          - yaml create id:doorkeys
          - yaml savefile:/scripts/doorkeys.dscript id:doorkeys
          }
        - yaml load:/scripts/doorkeys.dscript id:doorkeys
        - yaml set <def[tier]>.type:item id:doorkeys
        - if <context.args.get[3]> == hideflags {
          - yaml set "<def[tier]>.material:stone<proc[flags]>" id:doorkeys
          - yaml set "<def[tier]>.useflags:true" id:doorkeys
          } else {
          - yaml set "<def[tier]>.material:stone" id:doorkeys
          }
        - yaml set "<def[tier]>.display name:<def[tier]>" id:doorkeys
        - yaml set "<def[tier]>.lore:|:li@" id:doorkeys
        - yaml set "<def[tier]>.recipe:->:recipe1" id:doorkeys
        - yaml set "<def[tier]>.recipe:->:recipe2" id:doorkeys
        - yaml set "<def[tier]>.recipe:->:recipe3" id:doorkeys
        - narrate "<green><def[tier]> key created!"
        - yaml savefile:/scripts/doorkeys.dscript id:doorkeys
        - execute as_server "denizen reload scripts"
        - queue clear
      - case "edit":
        - if !<yaml[doorkeys].contains[<def[tier]>]> {
          - narrate "<red>Key not found!"
          - queue clear
          }
        - if <context.args.get[4]> == null {
          - narrate "<red>Please enter a value!"
          - queue clear
          }
        - yaml load:/scripts/doorkeys.dscript id:doorkeys
        - define value <context.args.get[4]>
        - choose <context.args.get[3]>:
          - case "display":
            - yaml set "<def[tier]>.display name:<def[value]>" id:doorkeys
            - yaml savefile:/scripts/doorkeys.dscript id:doorkeys
            - narrate "<green>Display of Key <def[tier]> set to<&co> <def[value]>!"
            - execute as_server "denizen reload scripts"
          - case "material":
            - if <def[tier].as_script.yaml_key[useflags]> == true {
              - yaml set <def[tier]>.material:<def[value]><proc[flags]> id:doorkeys
              } else {
              - yaml set <def[tier]>.material:<def[value]> id:doorKeys
              }
            - yaml savefile:/scripts/doorkeys.dscript id:doorkeys
            - narrate "<green>Material of Key <def[tier]> set to<&co> <def[value]>!"
            - execute as_server "denizen reload scripts"
          - case "lore":
            - if <context.args.get[5]> !== null {
              - define lore <context.args.get[5]>
              - define line <def[value]>
              - if <yaml[doorkeys].read[<def[tier]>.lore].as_list.size> < <def[line]> {
                - repeat <def[value].sub[<yaml[doorkeys].read[<def[tier]>.lore].as_list.size>]> {
                  - yaml set "<def[tier]>.lore:->:<&sp>" id:doorkeys
                  }
                }
              - yaml set <def[tier]>.lore[<def[line]>]:<def[lore]> id:doorkeys
              - yaml savefile:/scripts/doorkeys.dscript id:doorkeys
              - execute as_server "denizen reload scripts"
              - narrate "<green>Lore of Key <def[tier].lore> set to<&co> <def[value]>!"
              - queue clear
              }
            - yaml set <def[tier]>.lore:|:li@<def[value]> id:doorkeys
            - yaml savefile:/scripts/doorkeys.dscript id:doorkeys
            - execute as_server "denizen reload scripts"
            - narrate "<green>Lore of Key <def[tier].lore> set to<&co> <def[value]>!"
          - case "recipe":
            - if <def[value].as_list.size> > 9 {
              - narrate "<red>Entered too many items!"
              } else if <def[value].as_list.size> < 9 {
              - narrate "<red>Not enough items entered!"
              } else {
              - define value <def[value].as_list>
              - yaml set <def[tier]>.recipe[1]:i@<def[value].get[1]><&pipe>i@<def[value].get[2]><&pipe>i@<def[value].get[3]> id:doorkeys
              - yaml set <def[tier]>.recipe[2]:i@<def[value].get[4]><&pipe>i@<def[value].get[5]><&pipe>i@<def[value].get[6]> id:doorkeys
              - yaml set <def[tier]>.recipe[3]:i@<def[value].get[7]><&pipe>i@<def[value].get[8]><&pipe>i@<def[value].get[9]> id:doorkeys
              - yaml savefile:/scripts/doorkeys.dscript id:doorkeys
              - inventory open origin in@workbench[contents=li@i@stone]
              - narrate "<green>Current crafting recipe<&co>"
              - execute as_server "denizen reload scripts"
              }
        - queue clear
    - if <player.location.cursor_on[10].above.material> contains "door" {
      - define otherblock <player.location.cursor_on[10].above>
      - define text "& <player.location.cursor_on[10].above>"
      } else if <player.location.cursor_on[10].below.material> contains "door" {
      - define otherblock <player.location.cursor_on[10].below>
      - define text "& <player.location.cursor_on[10].below>"
      } else {
      - define otherblock none
      }
    - if <server.flag[doorkeys_t<def[tier]>].as_list> contains <player.location.cursor_on[10]> {
      - flag server doorkeys_t<def[tier]>:<-:<player.location.cursor_on[10]>
      - if <def[otherblock]> !== "none" {
        - flag server doorkeys_t<def[tier]>:<-:<def[otherblock]>
        }
      - narrate "<red><player.location.cursor_on[10].simple> <def[otherblock].simple> removed from the Tier <def[tier]> Door list!"
      } else {
      - flag server doorkeys_t<def[tier]>:->:<player.location.cursor_on[10]>
      - if <def[otherblock]> !== "none" {
        - flag server doorkeys_t<def[tier]>:->:<def[otherblock]>
        }
      - narrate "<green><player.location.cursor_on[10].simple> & <def[otherblock].simple> added to the Tier <def[tier]> Door list!"
      }

flags:
  type: procedure
  script:
  - determine "[flags=li@HIDE_ATTRIBUTES|HIDE_DESTROYS|HIDE_ENCHANTS|HIDE_PLACED_ON|HIDE_POTION_EFFECTS|HIDE_UNBREAKABLE]"

#  TeleportBack:
#    type: world
#    events:
#      on player jumps:
#      - run s@JumpCheck def:<context.location>
#      - if <player.location.direction.contains[north]> {
#        - define z 1
#        } else if <player.location.direction.contains[south]> {
#        - define z -1
#        } else {
#        - define z 0
#        }
#      - if <player.location.direction.contains[west]> {
#        - define x 1
#        } else if <player.location.direction.contains[east]> {
#        - define x -1
#        } else {
#        - define x 0
#        }
#      - teleport <player> <player.location.add[<def[x]>,-0.5,<def[z]>]> 

JumpCheck:
  type: task
  definitions: origin
  script:
  - wait 0.3s
  - if <player.location.x.abs.sub[<%origin%.x.abs.as_money>].as_money> < 0.2 || <player.location.z.abs.sub[<%origin%.z.abs.as_money>].as_money> < 0.2 {
    - teleport <player> %origin%
    }

#######################
### USAGE
####################
### - run s@Spiral_Particles def:Location|Effect|Length|Radius|Rotation
### Location: origin (for example, <player.eye_location>)
### Effect: the particle effect in the format "effect,data,qty,offset" (if not specified, flame,0,1,0)
### Length: the distance in blocks to go before stopping (if not specified, 20)
### Radius: radius of the spiral (if not specified, 1)
### Rotation: the angle to start the spiral from (if not specified, a decimal between 0 and tau)
#################
Spiral_Particles:
  type: task
  definitions: location|effect|maxLength|radius|rotation
  script:
  - if !<def[effect].exists> || <def[effect]> == "" {
    - define effect flame,0,1,0
    }
  - if !<def[maxLength].exists> || <def[maxLength]> == "" {
    - define maxLength 20
    }
  - if !<def[radius].exists> || <def[radius]> == "" {
    - define radius 1
    }
  - if !<def[rotation].exists> || <def[rotation]> == "" {
    - define rotation <util.random.decimal[0].to[<util.tau>]>
    }
  - define effect <def[effect].split[,]>
  - define length 0
  - define angularVelocity <util.pi.div[16]>
  - define pitchAngle <def[location].pitch.add[90].to_radians>
  - define yawAngle <def[location].yaw.mul[-1].to_radians>
  - while <def[length].is[LESS].than[<def[maxLength]>]> {
    - define vector l@<def[rotation].cos.mul[<def[radius]>]>,<def[length]>,<def[rotation].sin.mul[<def[radius]>]>
    - playeffect <def[location].add[<def[vector].rotate_around_x[<def[pitchAngle]>].rotate_around_y[<def[yawAngle]>]>]> "effect:<def[effect].get[1]||flame>" "data:<def[effect].get[2]||0>" "qty:<def[effect].get[3]||1>" "offset:<def[effect].get[4]||0>"
    - define rotation <def[rotation].add[<def[angularVelocity]>]>
    - define length <def[length].add[0.05]>
    - if <def[loop_index].mod[15]> == 0 {
      - wait 1t
      }
    }


######################################################################################################
######################################################################################################
##          _   _____    __     ___   _____                   ___                                   ##
##       __| |  \_   \  /__\   / __\ /__   \  __ _   __ _    / _ \  __ _  _ __  ___   ___  _ __     ##
##      / _` |   / /\/ / \//  / /      / /\/ / _` | / _` |  / /_)/ / _` || '__|/ __| / _ \| '__|    ##
##     | (_| |/\/ /_  / _  \ / /___   / /   | (_| || (_| | / ___/ | (_| || |   \__ \|  __/| |       ##
##      \__,_|\____/  \/ \_/ \____/   \/     \__,_| \__, | \/      \__,_||_|   |___/ \___||_|       ##
##                                                   |___/                                          ##
##   Made by Fortifier42                                                                            ##
######################################################################################################
######################################################################################################

IRC_Chat:
  debug: false
  type: format
  format: "<&sp><&7>[<&a>IRC<&7>] <&3><text>"

IRC_Config:
  type: yaml data

  # Change this to change the name your bot will display with in the IRC Channel!
  #Probably a good idea to change this so you don't get conflicts between other bots/users.
  botname: "Tag-Parser"

  # Change the following line to change the join command argument(s)!
  # At this stage, it does not change the /help irc output. :(
  joincmds: join|connect|start

  # Change the following line to change the quit command argument(s)!
  # At this stage, it does not change the /help irc output. :(
  quitcmds: quit|leave|exit|disconnect|stop

  # Change the following line to change the msg command argument(s)!
  # At this stage, it does not change the /help irc output. :(
  msgcmds: send|say|tell|msg|message

  # Change the following line to change the irc server to join!
  server: "irc.esper.net"

  # Change the following line to change the channel the bot will join!
  channel: "#Denizen-Dev"

  # Change the following line to determine what the prefix should be.
  # It is good to have a space after the trigger to ensure readability and compatability!
  trigger: ">tag "

  # Set this to "" to stop logging all together, or change the file which IRC actions will be logged to.
  # Currently only /irc send <message> and tag parsing are logged.
  logfile: plugins/Denizen/logs/ircbot.log

IRC_Command:
  debug: false
  type: command
  name: irc
  usage: /irc <&lt>(join/quit/msg <&lt>message<&gt>)<&gt>
  permission: irc.admin
  description: Used to connect, leave and send messages to IRC.
  script:
    - if <context.args.size> == 0 {
      - narrate format:IRC_Chat "<&c><script.yaml_key[usage]>"
      - queue clear
    }
    - define cmd <context.args.get[1]>
    - if <context.args.size> == 1 {
      - if <s@IRC_Config.yaml_key[joincmds].as_list.contains_any[%cmd%]> {
        - ~irc connect ircserver@<s@IRC_Config.yaml_key[server]>
        - irc raw ircserver@<s@IRC_Config.yaml_key[server]> "USER <s@IRC_Config.yaml_key[botname]> <s@IRC_Config.yaml_key[botname]>_ <s@IRC_Config.yaml_key[botname]>__ <s@IRC_Config.yaml_key[botname]>"
        - irc raw ircserver@<s@IRC_Config.yaml_key[server]> "NICK <s@IRC_Config.yaml_key[botname]>"
        - irc join ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]>
        - narrate format:IRC_Chat "Joined the IRC."
        - queue clear
      }
      else if <s@IRC_Config.yaml_key[quitcmds].as_list.contains_any[%cmd%]> {
        - ~irc leave ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]>
        - ~irc quit ircserver@<s@IRC_Config.yaml_key[server]>
        - narrate format:IRC_Chat "Left the IRC."
        - queue clear
      }
      else {
        - narrate format:IRC_Chat "<&c>Invalid command!"
        - queue clear
      }
    }
    else {
      - if <s@IRC_Config.yaml_key[msgcmds].contains_any[%cmd%]> {
        - define msg "<context.args.get[2].to[<context.args.size>].space_separated||null>"
        - if %msg% == null {
          - narrate format:IRC_Chat "<&c>No message has been specified."
          - queue clear
        }
        - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> <def[msg]>
        - narrate format:IRC_Chat "Sent message: <&f><&sq>%msg%<&sq>"
        - if <s@IRC_Config.yaml_key[logfile]> == "" queue clear
        - log "<player.name||Console> sent <&sq>%msg%<&sq>" file:<s@IRC_Config.yaml_key[logfile]>
      }
    }

IRC_Parsing:
  debug: false
  type: world
  events:
    on irc message:
      - if <context.channel> != "ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]>" || <context.message.substring[1,<s@IRC_Config.yaml_key[trigger].length>]> != <s@IRC_Config.yaml_key[trigger]> {
        - queue clear
      }
      - define tags "<context.message.after[<s@IRC_Config.yaml_key[trigger]>]>"
      - define parsed <parse.substring[1,300]:<def[tags]>>
      - irc message ircchannel@<s@IRC_Config.yaml_key[server]><s@IRC_Config.yaml_key[channel]> "<context.speaker><&r><&co> the tag <&sq><&b><def[tags]><&r><&sq> fills with <&sq><&b><def[parsed]><&r><&sq>"
      - if <s@IRC_Config.yaml_key[logfile]> == "" queue clear
      - log "<context.speaker> parsed <def[tags]>" file:<s@IRC_Config.yaml_key[logfile]>