extension/lua?

Could anyone please explain what are extension/lua files? I'm interested in /extension/lua/fireworks. I can see that in CSP-ParticlesFX/Fireworks I can select "Script used" and then "holidays" and nothing else. Where can I download extra scripts? What do I need to know to create a different script? I understand that I need to create another folder beside /lua/fireworks/holidays... but do I need to copy all the files? and what files should I look to modify? My idea is to create a script for random fireworks during every season, which means that fireworks can happen now and then, not always on every lap, but totally random.
 
Hello,

I don't think its possible, because all the stuff in /extension/lua/fireworks is for the look.

So the update function of the main loop already gets intensity and the type:
1661285528256.png

So the time, if fire work is shown is set outside by CSP.

So there are just types of styles, called HolidayType
1661285613462.png
,
which will later be used, to differ between different looks and schemes (sequences).

So there is no code to programm different activations by time. There is only this selection in CM:
1661285902502.png
 
Maybe there is a way to do it, but you need to dig in lua and CSP lua sdk.

You could write you code in the main loop and overwrite the intensity value:
1661286130587.png


Now you just have to code something, to control this variable. For this you can just use standard lua code. To get the seconds till AC session is start, you can use os.clock().

This little script will make firework for 10 seconds, every 20 seconds:
1661286754118.png


Just paste it after line 15:

local last = os.clock()
local duration = 0
function update(dt, intensity, holidayType)
audioPoolPrepare(dt)
if os.clock() - last > 10 then --time after last firework ends
intensity = 1
if duration == 0 then
duration = os.clock()
end
if os.clock() - duration > 10 then --duration of the firework
last = os.clock()
duration = 0
end
else
intensity = 0
end

local piecesSize = #piecesList
for i = piecesSize, 1, -1 do
if not piecesList:updateBase(dt) then
table.remove(piecesList, i)
end
end
local allowToSpawn = intensity > 0 and piecesSize < 150
for i = 1, pyrosSize do
pyros:update(dt, allowToSpawn, intensity, holidayType)
end
if holidayType == ac.HolidayType.Halloween then
intensity = math.min(intensity, 0.05)
end
-- ac.debug('items', piecesSize)
-- ac.debug('holiday', holidayType)
-- ac.debug('intensity', intensity)
-- runGC()
end
 

Attachments

  • 1661286502341.png
    1661286502341.png
    24.9 KB · Views: 73
Last edited:
Back
Top