Dynamic VetGroup name?

Can i use “dynamic” names for VetGroup name?

what i’ve tried:

                   index = math.random(1,99999999)                     ...                    burn[index]=CBE.VentGroup{                         ...                     }                                          dropSomething[index].fireBall = burn[index]:get("burn")                     dropSomething[index].fireBStart = burn[index]:start("burn")  

error:

main.lua:780: attempt to index global 'burn' (a nil value)  

780 is “}”

the end of: burn[index]=CBE.VentGroup{

I don’t know if that’s a bug or just the way things work in CBeffects, when i had this bug, the code was in different file and included in main.lua with require(effects). i took the code and past it in main.lua file and it’s working now. 

Did you first do
Burn={}

yes

It may be out of scope? Just guessing without seeing more code

To begin with, I wouldn’t create a lot of VentGroups themselves. They can be moderately large in storage size, and thus you might just want to create one VentGroup that re-emits each time you want a new “fireball”.

But, using your current multi-VentGroup approach, this might work for you:

[lua]

local burn={}

local function makeABurn()

  local index=math.random(9999)

  

  burn[index]=CBE.VentGroup{ … }

  

  dropSomething[index]=burn[index]:get(“burn”)

  burn[index]:start(“burn”)

end

[/lua]

As @jstrahan said, I can’t help much more without more code :slight_smile:

  • C

So I can use one VentGroup and have many “fireballs” moving to different directions and disappearing on different occasions? 

Just check with “collectgarbage(“count”)”, every created group took around 100kb of memory.

because right now i’m moving the fireball like this 

dropSomething[index].fireBall = burn[index]:get("burn") dropSomething[index].fireBall.y = dropSomething[index].fireBall.y +0.4  

Yep - a VentGroup emits particles. Each particle has its own attributes and values, and won’t conflict with other particles.

  • C

you might just want to create one VentGroup that re-emits each time you want a new “fireball”

like that? 

                    burn=CBE.VentGroup{                         {                             preset=burn[index],                             ...                         }                     }

Please give an example.

Something to this effect:

[lua]

local burn=CBE.VentGroup{

  { … }

}

local function makeABurn()

  burn:emit(“burn”)

end

[/lua]

  • C

didn’t workout. if new fireball created, the other older fireball appears on same position as the new one, as if i run without “burn:emit(“burn”)”

                    local function makeABurn()                         burn:emit("burn")                         dropSomething[index].fireBall = burn:get("burn")                         dropSomething[index].fireBStart = burn:start("burn")                         dropSomething[index].fireBall.x, dropSomething[index].fireBall.y = brick.x, brick.y                             end                                          makeABurn()  

Ok, so I think what you’re trying to do is create a fireball at a certain location. Is that correct?

If so, you should do something like this:

[lua]

local burn=CBE.VentGroup{

  {

    preset=“burn”,

    title=“burn”,

    emissionNum=15 – So it doesn’t go forever

  }

}

local function makeABurn()

  burn:translate(“burn”, fireballX, fireballY) – Wherever you want it

  burn:start(“burn”)

end

[/lua]

  • C

I don’t know if that’s a bug or just the way things work in CBeffects, when i had this bug, the code was in different file and included in main.lua with require(effects). i took the code and past it in main.lua file and it’s working now. 

Did you first do
Burn={}

yes

It may be out of scope? Just guessing without seeing more code

To begin with, I wouldn’t create a lot of VentGroups themselves. They can be moderately large in storage size, and thus you might just want to create one VentGroup that re-emits each time you want a new “fireball”.

But, using your current multi-VentGroup approach, this might work for you:

[lua]

local burn={}

local function makeABurn()

  local index=math.random(9999)

  

  burn[index]=CBE.VentGroup{ … }

  

  dropSomething[index]=burn[index]:get(“burn”)

  burn[index]:start(“burn”)

end

[/lua]

As @jstrahan said, I can’t help much more without more code :slight_smile:

  • C

So I can use one VentGroup and have many “fireballs” moving to different directions and disappearing on different occasions? 

Just check with “collectgarbage(“count”)”, every created group took around 100kb of memory.

because right now i’m moving the fireball like this 

dropSomething[index].fireBall = burn[index]:get("burn") dropSomething[index].fireBall.y = dropSomething[index].fireBall.y +0.4  

Yep - a VentGroup emits particles. Each particle has its own attributes and values, and won’t conflict with other particles.

  • C

you might just want to create one VentGroup that re-emits each time you want a new “fireball”

like that? 

                    burn=CBE.VentGroup{                         {                             preset=burn[index],                             ...                         }                     }

Please give an example.