Paste #18507: Edit of P#18506 - Untitled Paste

Date: 2015/07/22 11:21:34 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Drop:
  type: command
  speed: 0
  debug: false
  name: Drop
  description: Setze Drops
  usage: /drops
  aliases:
  - drops 
  allowed help:
  - determine true

  commandArgs:
    setzen:
      usage: '/drop setzen'
    erzeugen:
      usage: '/drop erzeugen'
    loeschen:
      usage: '/drop loeschen'
    anzeige:
      usage: '/drop anzeige'
    hinzu:
      usage: 'drop hinzu'

  script:
   - define command '<c.args.get[1].escaped||help]>'
   - define args '<script.list_keys[commandargs].alphanumeric.to_lowercase||li@>'
   - if !<def[args].contains[%command%]> {
    - inject local help
    }
    else {
     - inject local %command% }

  setzen:
   - if <player.is_op> {
    - if <c.args.get[2]||null> == null {
     - narrate "<yellow>[DropWorld] <gray>Du musst diesen Ort einen Namen geben!" 
     - queue clear }
    - if <yaml[spawning].list_keys[Drop]||null> contains <c.args.get[2]> {
     - narrate "<yellow>[DropWorld] <gray>Der Name exestiert schon!"
     - queue clear }
    - if <c.args.get[2].length> >= 9 {
     - narrate "<yellow>[DropWorld] <gray>Der Name darf nur maximal 8 Buchstaben lang sein!!"
     - queue clear }
    - if <c.args.get[3]||null> == null {
     - narrate "<yellow>[DropWorld] <gray>Bitte gib eine Wahrscheinlichkeit noch an!" 
     - queue clear }
    - if <c.args.get[3].as_int||null> == null {
     - narrate "<yellow>[DropWorld] <gray>Es sollte schon eine Zahl sein!"
     - queue clear }    
    - if <c.args.get[3]> <= 0 || <c.args.get[3]> > 1000 {
     - narrate "<yellow>[DropWorld] <gray>Es stehen dir Zahlen zwischen 1 und 1000 zur Verf<&uuml>gung!" 
     - queue clear }    
    - define name <c.args.get[2]>
    - define location <player.location.simple>
    - define wahrscheinlichkeit <c.args.get[3]>
    - define sichtwinkel <player.location.cursor_on.add[0.5,0,0.5]>
    - narrate %sichtwinkel%
    - foreach <player.location.find.blocks[chest].within[10]> {
     - if %value% == %sichtwinkel% {
      - define slotzahl 1
      - while true {      
       - define itemm <%value%.inventory.slot[<def[slotzahl].as_int>].simple>
       - if <%value%.inventory.slot[1].simple> == i@air {
        - narrate "<yellow>[DropWorld] <red> Es muss aufjedenfall in Slot 1 ein Item sein! Dies wird immer gedropt egal welche wahrscheinlichkeit, dient dazu immer ein item spawnen zu lassen!"
        - queue clear }        
       - if %itemm% !== i@air {
        - define itemanzahl <%value%.inventory.qty[%itemm%].as_int>
        - if <yaml[spawning].list_keys[Drop.%name%.item]> !contains %itemm% {
         - yaml id:spawning set Drop.%name%.item.%itemm%.itemanzahl:->:%itemanzahl%
         - yaml id:spawning set Drop.%name%.item.%itemm%.wahrscheinlichkeit:->:%wahrscheinlichkeit% } }
       - define slotzahl <math:%slotzahl%+1>
       - if <def[slotzahl]> == 28 {
        - narrate "<yellow>[DropWorld] <gray>Gespeichert als <yellow>N:<gray>[%name%] <yellow>O:<gray>[%location%] <yellow>I:<gray>[S. Kiste] <yellow>A:<gray>[S. Kiste] <yellow>W:<gray>[%wahrscheinlichkeit%]"
        - yaml id:spawning set Drop.%name%.Ort:->:%location%        
        - yaml savefile:dropeinstellung/spawning.yml id:spawning
        - queue clear }
      } 
     }
    }
    - narrate "<yellow>[DropWorld] <red>Cursor muss sich auf einer Truhe in deiner n<&auml>he befinden!"
    - queue clear
   }
   - narrate "<yellow>[DropWorld] <red>Du hast auf diesen Befehl kein Zugriff!"
   - queue clear

  loeschen:
   - if <player.is_op> {
    - if <c.args.get[2]||null> == null {
     - narrate "<yellow>[DropWorld] <gray>Du musst diesen Ort einen Namen geben!" 
     - queue clear }
    - if <yaml[spawning].list_keys[Drop]||null> !contains <c.args.get[2]> {
     - narrate "<yellow>[DropWorld] <gray>Der Name exestiert nicht in deiner Liste!"
     - queue clear }
    - define name <c.args.get[2]>
    - narrate "<yellow>[DropWorld] <gray>Deine Position %name% wurde gel<&ouml>scht!"
    - yaml id:spawning set Drop.%name%:!
    - yaml savefile:dropeinstellung/spawning.yml id:spawning
    - queue clear
   }
   - narrate "<yellow>[DropWorld] <red>Du hast auf diesen Befehl kein Zugriff!"
   - queue clear       

  erzeugen:
    - if <player.is_op> || <c.server> {
      - define eingabe <context.args.get[2]||null>
      - if %eingabe% == null {
        - narrate "<yellow>[DropWorld] <gray>Bitte gib einen Namen ein!"
        - queue clear
        }
      - if <yaml[spawning].list_keys[Drop]||null> !contains %eingabe% {
        - narrate "<yellow>[DropWorld] <gray>Der Name exestiert nicht in der Liste!"
        - queue clear 
        }    
      - define ort <yaml[spawning].read[drop.%eingabe%.ort].as_string>
      - foreach <yaml[spawning].list_keys[drop.%eingabe%.item]> {
        - narrate %value%
        - flag server item_%eingabe%:->:%value% 
        }
      - while true {
        - define zahl <util.random.int[1].to[27]>
        - define itemm <server.flag[item_%eingabe%].as_list.get[<def[zahl]>].simple||null>
        - if %itemm% !== null { 
          - define itemanzahl <yaml[spawning].read[drop.%eingabe%.item.%itemm%.itemanzahl].as_String>
          - define wahrscheinlichkeit <yaml[spawning].read[drop.%eingabe%.item.<def[itemm].simple>.wahrscheinlichkeit].as_string>
          - while stop 
          }
        }
      - if <util.random.int[1].to[1000]> <= %wahrscheinlichkeit% {
         - drop %itemm% location:%ort% qty:%itemanzahl%
         - flag server item_%eingabe%:!
         - narrate "wurde gespawnt: %itemm% mit %wahrscheinlichkeit%"
         - queue clear
        } else {
        - define %itemm% <server.flag[item_%eingabe%].as_list.get[1]>
        - drop %itemm% location:%ort% qty:%itemanzahl%
        - flag server item_%eingabe%:!
        - queue clear
        }
      } 
    - narrate "<yellow>[DropWorld] <red>Du hast auf diesen Befehl kein Zugriff!"
    - queue clear    

  anzeige:
   - if <player.is_op> {
    - define count 1
    - narrate "<gray>_______________<yellow>[Drop World]<gray>_______________"
    - narrate ""
    - foreach <yaml[spawning].list_keys[Drop]||null> {
     - narrate "<red>[<def[count].as_int>] <yellow>N: <gray>%value% <yellow>O: <gray><yaml[spawning].read[Drop.%value%.ort].as_string||null> <yellow>I: <gray><yaml[spawning].read[Drop.%value%.item].as_string||null> <yellow>A: <gray><yaml[spawning].read[Drop.%value%.itemanzahl].as_string||null> <yellow>W: <gray><yaml[spawning].read[Drop.%value%.wahrscheinlichkeit].as_string||null>"     
     - define count <math:%count%+1> }
    - queue clear
   }
   - narrate "<yellow>[DropWorld] <red>Du hast auf diesen Befehl kein Zugriff!"
   - queue clear

  help:
   - if <player.is_op> {
    - narrate "<gray>_______________<yellow>[Drop World]<gray>_______________"
    - narrate ""
    - narrate "<yellow>/drop setzen NAME ITEMANZAHL WAHRSCHEINLICHKEIT  <gray>[Drop-Punkt unter Spieler]"
    - narrate "<yellow>/drop loeschen NAME  <gray>[L<&ouml>scht den Drop-Punkt]"
    - narrate "<yellow>/drop erzeugen NAME  <gray>[Spawnt Item am Drop-Punkt]"
    - narrate "<yellow>/drop anzeige  <gray>[Zeigt alle Drop-Orte an]"
   }