GE Lua Documentation

Press F to search!

tableMergeRecursive

Definition


-- @/lua/common/utils.lua:653

-- http://stackoverflow.com/questions/1283388/lua-merge-tables
-- IMPORTANT: this is overwriting key/values pairs and will not merge array/lists as you might expect
function tableMergeRecursive(t1, t2)
  for k, v in pairs(t2) do
    if type(v) == "table" and type(t1[k]) == "table" then
      tableMergeRecursive(t1[k], t2[k])
    else
      t1[k] = v
    end
  end
  return t1
end

Callers

@/lua/vehicle/powertrain/electricMotor.lua
  device.soundConfiguration[reference] = device.soundConfiguration[reference] or {}
  device.soundConfiguration[reference].params = tableMergeRecursive(device.soundConfiguration[reference].params or {}, params)
  device.soundConfiguration[reference].soundID = soundID
@/lua/vehicle/controller/vivaceGauges.lua
  local config = {unit = settings.getValue("uiUnitLength") or "metric"}
  config = tableMergeRecursive(jbeamData, config)
@/lua/vehicle/extensions/dynamicVehicleData.lua
    log("D", logTag, "Saving...")
    tableMergeRecursive(data, newData)
    jsonWriteFile(filepath, data, true)
@/lua/vehicle/energyStorage.lua
  for _, jbeamData in pairs(deepcopy(v.data.energyStorage or {})) do
    tableMergeRecursive(jbeamData, v.data[jbeamData.name] or {})
@/lua/common/utils.lua
    if type(v) == "table" and type(t1[k]) == "table" then
      tableMergeRecursive(t1[k], t2[k])
    else
@/lua/vehicle/controller/gauges/analogOdometer.lua
    if k:sub(1, #"configuration_") == "configuration_" then
      tableMergeRecursive(configData, v)
    end
@/lua/vehicle/powertrain.lua
    for _, jbeamData in pairs(deepcopy(v.data.powertrain)) do
      tableMergeRecursive(jbeamData, v.data[jbeamData.name] or {})
@/lua/vehicle/powertrain/combustionEngine.lua
  device.soundConfiguration[reference] = device.soundConfiguration[reference] or {}
  device.soundConfiguration[reference].params = tableMergeRecursive(device.soundConfiguration[reference].params or {}, params)
  device.soundConfiguration[reference].soundID = soundID
@/lua/vehicle/controller.lua
      if controller and type(controller) == "table" then
        local data = tableMergeRecursive(c, v.data[k] or {})
        c.name = c.name or k
    if controller.getState then
      tableMergeRecursive(data, controller.getState())
    end
@/lua/ge/extensions/util/configListGenerator.lua
      local aggregateFilter = deepcopy(seller.filter)
      tableMergeRecursive(aggregateFilter, subFilter)
      table.insert(result, aggregateFilter)
@/lua/vehicle/controller/esc.lua
  if v.userSettings and v.userSettings.escConfig then
    escConfigs = tableMergeRecursive(escConfigs, v.userSettings.escConfig)
  end
@/lua/vehicle/controller/gauges/genericGauges.lua
    if k:sub(1, #"configuration_") == "configuration_" then
      tableMergeRecursive(configData, v)
    end
@/lua/vehicle/controller/driveModes.lua
    if k:sub(1, #"modes") == "modes" then
      tableMergeRecursive(modeData, v)
    end
@/lua/vehicle/controller/vehicleController/vehicleController.lua
  if controlLogicModule.getState then
    tableMergeRecursive(data, controlLogicModule.getState())
  end
@/lua/vehicle/sounds.lua

      tableMergeRecursive(soundBank, tmp)
    else
@/lua/ge/extensions/core/camera.lua
    camera.defaultRotation = nil
    tableMergeRecursive(camera, jbeamConfig)
    if type(camera.onVehicleCameraConfigChanged) == 'function' then
    if data.globalCameras[camName] then
      tableMergeRecursive(cam, deserialize(data.globalCameras[camName]))
      if cam.onDeserialized then cam:onDeserialized() end
        if svdata.cameras[camName] then
          tableMergeRecursive(cam, deserialize(svdata.cameras[camName]))
        end