Skip to content

Advanced Option

jdeon edited this page Apr 19, 2026 · 4 revisions

Since v2.1.0

The attribute advanced exists in the input to handle advance behaviour

Variables

advanced.variables You can add variables inside with the name of your choice with a value using a default pattern or a function (only using operators, Math object and condition).

  [...]
  "advanced" : {
    "variables" : {
      "a" : "5_10",
      "c" : ({a, d}) => Math.cos(a) * 2,
    }
  }

These variables will be compute at the particles generation and be propagate in all input with the name of the input inside {{}} to link the value between multiple input.

game.modules.get("particule-fx").api.emit.spray({
    source :source.id, 
    target: targetId , 
    particleVelocityStart : "{{b}}",
    particleAngleStart : "{{a}}",
    particleSizeStart : "{{d}}%",
    advanced: {
        variables : {
            a : "1_360",
            b : ({c}) => (c+1) * 100,
            c : ({a, d}) => Math.cos(a),
            d : ({a}) => a/10 +5,
        }
    }
})

Example
Hypnose macro

game.modules.get("particule-fx").api.emit.gravit( "charm",{
    source :source.id, 
    particleVelocityStart : 0,
    particleRadiusStart : "100%",
    particleRadiusEnd :0,
    particleSizeStart : {x : "1%", y: 5},
    particleAngleStart : "{{a}}",
    particleRotationStart : "{{a}}",
    advanced: {
        variables : {
            a : "0_360",
        }
    }
})

Timed focus input

For function variables the following input is reserved and if used the variables will be computed at each frame (for this reason, it could slow the time on the frame) :

  • "dt" : /Delta time with last frame
  • "lt": Lifetime (time of existence in millisecond)
  • "tp : Percentage of living time (0 at creation and 1 at death)

Examples

This behavior could be used to use another than linear change : Square root velocity

game.modules.get("particule-fx").api.emit.spray('breath','fire',{
    source :source.id, 
    target: targetId , 
    particleVelocityStart : "{{a}}",
    advanced: {
        variables : {
            a : ({tp}) => 500* (1-Math.pow(tp, 1/3)),
        }
    }
})

To change the behavior during the lifetime : Particles with time behavior

game.modules.get("particule-fx").api.emit.gravit("silver", {
    source :source.id,
    spawningFrequence: 1,
    maxParticles: 20,
    emissionDuration: 500,
    particleLifetime: [500, 750],
    particleVelocityStart : 0,
    particleRadiusStart : "100%",
    particleRadiusEnd : 0,
    particleSizeStart : {x : "{{a}}%", y: "2%"},
    particleAngleStart : "{{b}}",
    particleRotationStart : "{{b}}",
    alphaEnd: 1,
    advanced: {
        variables : {
            a : ({tp}) => {if(tp < 5/10){ return tp * 98 + 2 } else { return 196 * (1 - tp) + 2}},
           b : "0_360"
        }
    }
})

Known issue

Decimal number

For now, the dot is forbidden in function variable (except in "Math.") so decimal number is not possible. You need to either store the number in a non-function variable and use it as parameter or use a fration version (4.21 become 421/100).

Clone this wiki locally