VE Lua Documentation

Press F to search!

torsionBarBroken

Definition


-- @/lua/vehicle/beamstate.lua:774

local function torsionBarBroken(id, energy)
  if v.data.torsionbars[id] ~= nil then
    local torsionbar = v.data.torsionbars[id]

    --this code closely mimmicks what happens in beamBroken, but for torsionbars
    if torsionbar.breakGroup then
      if type(torsionbar.breakGroup) ~= "table" and breakGroupCache[torsionbar.breakGroup] == nil then
        -- shortcircuit in case of broken single breakGroup
      else
        local breakGroups = type(torsionbar.breakGroup) == "table" and torsionbar.breakGroup or {torsionbar.breakGroup}
        for _, g in ipairs(breakGroups) do
          if breakGroupCache[g] then
            props.hidePropsInBreakGroup(g)

            -- breakGroupType = 0 breaks the group
            -- breakGroupType = 1 does not break the group but will be broken by the group
            if torsionbar.breakGroupType == 0 or torsionbar.breakGroupType == nil then
              breakBreakGroup(g)
            end
          end
        end
      end
    end
  end
end

Callers

@/lua/vehicle/main.lua
function onTorsionbarBroken(id, energy)
  beamstate.torsionBarBroken(id, energy)
  extensions.hook("onTorsionbarBroken", id, energy)