Particalsystem change TTL (Time to life) with Lua

  • #1, by stothewThursday, 30. August 2018, 12:41 6 years ago
    Hi there,

    is there an easy way to change the partical min/max lifetime with lua?
    i found "ParticleMaxLife" in Datastructure documentation but have no glue how to access to particle properties in general.

    Many thanks!

    Forum Fan

    127 Posts


  • #2, by SimonSSunday, 02. September 2018, 21:12 6 years ago
    Hi,

    it's changeable via lua for a specific object that runs particles.

    local maxLife = 2.0
    
    local minLife = 1.0
    
    graphics.getParticles(game.CurrentScene.Objects.object).life = {0.0,minLife,-10000,0.0,maxLife} 

    Thread Captain

    1582 Posts

  • #3, by stothewSunday, 02. September 2018, 22:33 6 years ago
    hi Simon!

    Thanks for the help!

    but at least with my knowlege it does not work.

    no matter if i put in the full path or use currentScene
    graphics.getParticles(game.CurrentScene.Objects.partikel_schleim_01).life = {0.0,minLife,-10000,0.0,maxLife}
    graphics.getParticles(Scenes.akw_sicherheitsgang_minispiel_01.Objects.partikel_schleim_01).life = {0.0,minLife,-10000,0.0,maxLife}
    I get:
    22:19:55.559:[string "(30,49)"]:4: attempt to index a nil value
    22:19:55.559:stack traceback:
        [C]: in function 'debugerror'
        [string "function debugfunc(err) debugerror(err) end"]:1: in function '__newindex'
        [string "(30,49)"]:4: in main chunk
    22:19:55.559:Failed to run string in Lua: 
    22:19:55.559:String content: local maxLife = 5.0
    local minLife = 1.7
    
    graphics.getParticles(Scenes.akw_sicherheitsgang_minispiel_01.Objects.partikel_schleim_01).life = {0.0,minLife,-10000,0.0,maxLife}

    I also tried to give him the path to the paticlecontainer
    ParticleContainers.T5_minispiel_schleim

    But no luck.

    What I´m doing wrong? any Ideas?

    Forum Fan

    127 Posts

  • #4, by SimonSSunday, 02. September 2018, 22:35 6 years ago
    Are the particles running when you execute the script ?

    Thread Captain

    1582 Posts

  • #5, by stothewSunday, 02. September 2018, 22:36 6 years ago
    no. my thought was "config" them then run. Should they?

    Forum Fan

    127 Posts

  • #6, by SimonSSunday, 02. September 2018, 22:38 6 years ago
    Why would you change them before you run them? That's done in the editor. This function is only for changing variables at runtime of the particle system.

    Thread Captain

    1582 Posts

  • #7, by stothewSunday, 02. September 2018, 22:46 6 years ago
    i have a minigame where you have to fill barrels with slime so while the "minigame" runs the particle effects is turned on and off. i config them before the next barrel is filled.. (the barrels have all different size)

    Anyway It works well if i run it while filling.. so thanks a lot!

    Forum Fan

    127 Posts