GE Lua Documentation

Press F to search!

openVehicleSelectorForMissionBySetting

Definition


-- @/lua/ge/extensions/gameplay/missions/missionScreen.lua:802



M.openVehicleSelectorForMissionBySetting = function(mId, settingKey)
  local m = gameplay_missions_missions.getMissionById(mId)
  if not m then return end
  local settings = m:getUserSettingsData() or {}
  local setting, settingIdx = nil, nil
  for _, s in ipairs(settings) do
    if s.key == settingKey then
      setting = s
      settingIdx = i
    end
  end

  ui_vehicleSelector_general.openVehicleSelectorForChallenge(function(model, config)
    M.setPreselectedMissionId(mId)
    M.setPreselectedPage("settings")
    if model and config then
      if m._lastUserSettingsOutsideOfMission then
        for _, s in ipairs(m._lastUserSettingsOutsideOfMission) do
          if s.key == settingKey then
            for _, option in ipairs(setting.values) do
              if option.type == "custom" and option.viaUserSettingsKey == 'setupModuleVehiclesCustom' then
                s.value = option.v
                for _, l in ipairs(m._lastUserSettingsOutsideOfMission) do
                  if l.key == option.viaUserSettingsKey then
                    l.value = {model = model, config = config}
                  end
                end
              end
            end
          end
        end
      end
    end
    guihooks.trigger('MenuOpenModule','mission-details')
  end
  )
end

Callers