GE Lua Documentation

Press F to search!

workload

Definition


-- @/lua/ge/extensions/gameplay/statisticModules/watchRollover.lua:28

local function watchRollover( v , vid , dtSim)
  if vid ~= myvid then cancel() end
  simTime = simTime + dtSim
  myvid = vid

  -- vpos:set(v:getPositionXYZ())
  vup:set(v:getDirectionVectorUpXYZ())
  vdir:set(v:getDirectionVectorXYZ())
  velocity:set(v:getVelocityXYZ())
  vright:setCross(vdir, vup)
  vright:normalize()

  if vup.z > THRESHOLD then
    if triggered then
      if lastRoof + TIMEOUT > simTime and lastUpright + TIMEOUT*2 > simTime then
        -- log("I","","rolllllllll")
        gameplay_statistic.metricAdd("vehicle/rollover",1)
      -- else
      --   log("I","","rol timeout r" ..dumps(lastRoof + TIMEOUT > simTime).."\tup="..dumps(lastUpright + TIMEOUT*2 > simTime))
      end
      cancel()
    end
    if simTime > lastUpright+REFRESH then
      lastUpright = simTime
    end
  end
  if vup.z < -THRESHOLD and abs(vdir:dot(velocity)) lastRoof+REFRESH then
    -- log("I","","roof")
    triggered = true
    lastRoof = simTime
  end
  -- print( dumps(vup.z).."\t"..dumps(vdir:dot(velocity)) .."\ttr="..dumps(triggered) )
end

Callers