VE Lua Documentation

Press F to search!

roundNear

Definition


-- @/lua/common/mathlib.lua:1164

-- to round to Nth decimal use roundNear(x, 1e-N)
function roundNear(x, m)
  return floor(.5 + x/m)*m
end

Callers

@/lua/vehicle/controller/vehicleController/vehicleController.lua
          wheelSlipUp = shiftPreventionData.wheelSlipShiftUp,
          lockupRatio = roundNear(electrics.values.lockupClutchRatio or 0, 1e-2)
        }
@/lua/common/mathlib.lua

-- to round to Nth decimal use roundNear(x, 1e-N)
function roundNear(x, m)
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/veJBeamBeautifier.lua
                              if roundingEnabledPtr[0] then
                                astNode[2] = roundNear(astNode[2], 10^-decimalPlacesPtr[0])
                                astNode[3] = decimalPlacesPtr[0]
    if ty1 == 'number' then
      local t1New = roundingEnabledPtr[0] and roundNear(t1, 10^-decimalPlacesPtr[0]) or t1
      return math.abs(t1New - t2) < 0.0001
@/lua/vehicle/bdebugImpl.lua
local function vecRoundNear(v, m)
  v.x = roundNear(v.x, m)
  v.y = roundNear(v.y, m)
  v.x = roundNear(v.x, m)
  v.y = roundNear(v.y, m)
  v.z = roundNear(v.z, m)
  v.y = roundNear(v.y, m)
  v.z = roundNear(v.z, m)
end
local function getPosHash(v, offX, offY, offZ)
  local x, y, z = roundNear(v.x, overlapSize), roundNear(v.y, overlapSize), roundNear(v.z, overlapSize)
  local hash = bit.bxor(bit.bxor((x + (offX or 0)) * 73856093, (y + (offY or 0)) * 19349663), (z + (offZ or 0)) * 83492791)
local function getPosHash(v, offX, offY, offZ)
  local x, y, z = roundNear(v.x, overlapSize), roundNear(v.y, overlapSize), roundNear(v.z, overlapSize)
  local hash = bit.bxor(bit.bxor((x + (offX or 0)) * 73856093, (y + (offY or 0)) * 19349663), (z + (offZ or 0)) * 83492791)
local function getPosHash(v, offX, offY, offZ)
  local x, y, z = roundNear(v.x, overlapSize), roundNear(v.y, overlapSize), roundNear(v.z, overlapSize)
  local hash = bit.bxor(bit.bxor((x + (offX or 0)) * 73856093, (y + (offY or 0)) * 19349663), (z + (offZ or 0)) * 83492791)
@/lua/ge/extensions/core/vehicle/partmgmt.lua
        entry.offsetData.offset = {
          x = roundNear(offsetPos.x, 0.001),
          y = roundNear(offsetPos.y, 0.001),
          x = roundNear(offsetPos.x, 0.001),
          y = roundNear(offsetPos.y, 0.001),
          z = roundNear(offsetPos.z, 0.001),
          y = roundNear(offsetPos.y, 0.001),
          z = roundNear(offsetPos.z, 0.001),
          rx = roundNear(math.deg(offsetEuler.x), 0.1),
          z = roundNear(offsetPos.z, 0.001),
          rx = roundNear(math.deg(offsetEuler.x), 0.1),
          ry = roundNear(math.deg(offsetEuler.y), 0.1),
          rx = roundNear(math.deg(offsetEuler.x), 0.1),
          ry = roundNear(math.deg(offsetEuler.y), 0.1),
          rz = roundNear(math.deg(offsetEuler.z), 0.1),
          ry = roundNear(math.deg(offsetEuler.y), 0.1),
          rz = roundNear(math.deg(offsetEuler.z), 0.1),
        }
        entry.offsetData.offset = {
          rx = roundNear(math.deg(offsetEuler.x), 0.1),
          ry = roundNear(math.deg(offsetEuler.y), 0.1),
          rx = roundNear(math.deg(offsetEuler.x), 0.1),
          ry = roundNear(math.deg(offsetEuler.y), 0.1),
          rz = roundNear(math.deg(offsetEuler.z), 0.1),
          ry = roundNear(math.deg(offsetEuler.y), 0.1),
          rz = roundNear(math.deg(offsetEuler.z), 0.1),
        }
@/lua/vehicle/controller/braking/hydraulicPumpBrake.lua
      txt = "vehicle.hydraulicPumpBrake.hillAssist",
      context = {coef = (roundNear(hillAssistCoef, 0.01) * 100) .. "%"}
    },
@/lua/ge/extensions/career/modules/partShopping.lua

  part.finalValue = math.max(roundNear(career_modules_valueCalculator.getPartValue(part), 5) - 0.01, 0)
  return part