Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

Particalsystem change TTL (Time to life) with Lua

  • #1, by stothew 8 years ago Zitieren
    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!
  • #2, by SimonS 8 years ago Zitieren
    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} 

  • #3, by stothew 8 years ago Zitieren
    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?
  • #4, by SimonS 8 years ago Zitieren
    Are the particles running when you execute the script ?
  • #5, by stothew 8 years ago Zitieren
    no. my thought was "config" them then run. Should they?
  • #6, by SimonS 8 years ago Zitieren
    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.
  • #7, by stothew 8 years ago Zitieren
    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!