Pass variable into vent group build function

I’m a little stuck in trying to pass variable into vent group build function.

for example:

in vent group i’ve this function

            build=function(size)                 local size=math.random(size, size)  

How can i pass the “size” variable?

what i’ve tried

function fireBall(x,y,size)     local group = burn:get("burn")     group.x, group.y = x, y     group.size = size     burn:start("burn") end fireBall(20,220, 15)

    

burn=CBE.VentGroup{         {             preset="burn",             color={{255, 111, 0}, {255, 70, 0}}, -- Reddish-orange colors             build=function(size)                 local size=math.random(size, size)                 return display.newImageRect("media/generic\_particle.png", size, size)             end,             onCreation=function()end, -- See the note for the ice comet             x=20,             y=20,             perEmit=2,             positionType="inRadius",             posRadius=20,             emitDelay=50,             fadeInTime=500,             lifeSpan=500, -- Particles are removed sooner than the ice comet             lifeStart=500,             endAlpha=0,             physics={                 relativeToSize=false,                 sizeX=-0.01,                 sizeY=-0.01,                 autoAngle=false,                 angles={135},                 relativeToSize=false,                 velocity=3,                 xDamping=1,                 gravityY=-0.01,                 gravityX=0.01             }         },         {             preset="burn", -- Not the smoke preset because it's just about the same as the burn effect, just with a few changes             title="smoke", -- The smoke vent             color={{100}},             build=function()                 local size=math.random(120, 140)                 return display.newImageRect("media/smoke.png", size, size)             end,             propertyTable={blendMode="screen"}, -- Lighten the comet slightly             onCreation=function()end,             perEmit=1,             y=384,             x=512,             positionType="inRadius",             posRadius=20,             emitDelay=50,             fadeInTime=500,             lifeSpan=500,             lifeStart=500,             alpha=0.5,             endAlpha=0,             physics={                 relativeToSize=false,                 sizeX=-0.01,                 sizeY=-0.01,                 autoAngle=false,                 angles={90},                 relativeToSize=false,                 velocity=3,                 xDamping=1,                 gravityY=-0.01,                 gravityX=0.01             }         }     }  

Variables can’t be passed into the build function itself unless you edit the library. However, you can use a property belonging to the vent to do it, using just a few changes to your functions:

[lua]

function fireBall(x,y,size)
    local group = burn:get(“burn”)
    group.x, group.y = x, y
    group.size = size
    burn:start(“burn”)
end
fireBall(20,220, 15)

[/lua]

And then for the build function (the only argument passed to the build function - at least with the most recent version - is the vent itself):

[lua]

build=function(vent)
    – local size=math.random(vent.size, vent.size) – Not sure why you’re using math.random - you could just as easily do this, and it would take less time:

   local size=vent.size

   (build particle)

end

[/lua]

Worked like a charm, thanks!

Variables can’t be passed into the build function itself unless you edit the library. However, you can use a property belonging to the vent to do it, using just a few changes to your functions:

[lua]

function fireBall(x,y,size)
    local group = burn:get(“burn”)
    group.x, group.y = x, y
    group.size = size
    burn:start(“burn”)
end
fireBall(20,220, 15)

[/lua]

And then for the build function (the only argument passed to the build function - at least with the most recent version - is the vent itself):

[lua]

build=function(vent)
    – local size=math.random(vent.size, vent.size) – Not sure why you’re using math.random - you could just as easily do this, and it would take less time:

   local size=vent.size

   (build particle)

end

[/lua]

Worked like a charm, thanks!