Objects Break Particle Trigger LUA
Thank you to @TonyCartony for answering some of my questions.
He gave me a LUA script that basically called me a "BUM!" when a beam breaks. After a few hours I was able to change the LUA to spawn particles when breaking.
LUA from Tony...
local M = {}
local wantedBeam = -1
local function onReset()
wantedBeam = -1
for _, beam in pairs(v.data.beams) do
if v.data.nodes[beam.id1].name == "a0" and v.data.nodes[beam.id2].name == "nl0" then
print("wanted beam found " .. tostring(beam.cid))
wantedBeam = beam.cid
end
end
end
local function updateGFX(dt)
for _, beam in pairs(v.data.beams) do
local beamBroken = obj:beamIsBroken(beam.cid)
if beamBroken and beam.cid == wantedBeam then
print("BUM!")
end
end
end
M.onReset = onReset
M.updateGFX = updateGFX
return M
My modification............
local M = {}
local wantedBeam = -1
local a0
local function onReset()
wantedBeam = -1
for _, beam in pairs(v.data.beams) do
if v.data.nodes[beam.id1].name == "a0" and v.data.nodes[beam.id2].name == "b4" then
print("wanted beam found " .. tostring(beam.cid))
wantedBeam = beam.cid
end
end
end
local function updateGFX(dt)
for _, beam in pairs(v.data.beams) do
local beamBroken = obj:beamIsBroken(beam.cid)
if beamBroken and beam.cid == wantedBeam then
obj:addParticleByNodesRelative(0, 0, 25, 13, 0.01, 15)
end
end
end
M.onReset = onReset
M.updateGFX = updateGFX
return M
This was one of those days I was really feeling great figuring something out!
Not all days are good days of course... Enjoy the good ones when they happen. Haha, I was so happy I remade the song Particle Man by They Might Be Giants :)
Other Videos By BeamNG - TerryMartinART - Mods Assets Solutions
2023-01-20 | Beach Work |
2023-01-18 | Island Doodle 2 |
2023-01-17 | Island |
2023-01-15 | An idea for a small level |
2023-01-15 | Workflow I use for creating new Forest Brush Assets. |
2023-01-14 | Grass used as Forest Brush rather than as a Ground Cover |
2023-01-14 | Train Crash |
2023-01-14 | Making custom train tracks in Blender for BeamNG that bend - With Blender file included |
2023-01-13 | Time Lapse - What I did to figure it out - crawler wheel scaling |
2023-01-13 | Crawler's Wheels MONSTER TRUCK size! |
2023-01-13 | Objects Break Particle Trigger LUA |
2023-01-12 | Making the Mini Game - Ice Sheet Mod and Very Basic Track included seen in video |
2023-01-12 | January 12, 2023 |
2023-01-12 | Don't Break the ICE - Mini Game Idea |
2023-01-11 | Making Cube Jbeam - W/Audio |
2023-01-11 | Making a Duck Mod - Sorry Mic went out |
2023-01-11 | Duck - Mod - For Kid Videos |
2023-01-11 | Anchored Burnside requested - and served |
2023-01-11 | January 11, 2023 |
2023-01-10 | Small Island - Pre PBR terrain Paint - |
2023-01-10 | Project3 Old Old 2nd track I tried to make |