Paste #18345: Spiral Particles v0.4

Date: 2015/07/18 17:59:00 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#########################
### Spiral Particles v0.4
#######################
### 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[,].limit[4]>
  - 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[10]> == 0 {
      - wait 1t
      }
    }