GE Lua Documentation

Press F to search!

generateAttempts

Definition


-- @/lua/ge/extensions/gameplay/missions/progress.lua:1747

M.generateAttempts = function(id, amount, dumpChange)
  local mission = gameplay_missions_missions.getMissionById(id)
  if not mission then
    plog("E", "", "Trying to saveMissionAttempt nonexitent mission by ID: " .. dumps(id))
    return
  end
  if not mission.getRandomizedAttempt then
    return
  end
  local allProgressKeys = tableKeysSorted(mission.saveData.progress)
  for _, progressKey in ipairs(allProgressKeys) do
    for i = 1, amount do
      local attempt = M.newAttempt(mission:getRandomizedAttempt())
      local totalChange = M.aggregateAttempt(id, attempt, progressKey)
      if dumpChange then
        dump(totalChange)
      end
    end
  end
  if career_career and career_career.isActive() then
    if not career_modules_missionWrapper then
      plog("E", "", "Trying to save mission with career_modules_missionWrapper not loaded but career_career is active ("..dumps(id)..")")
    else
      career_modules_missionWrapper.saveMission(id)
    end
  else
    M.saveMissionSaveData(id)
  end

end

Callers

@/lua/ge/extensions/editor/missionEditor.lua
          if im.MenuItem1("Generate 25 Attempts") then
            gameplay_missions_progress.generateAttempts(clickedMission.id, 25, true)
          end
            for _, mission in ipairs(missionList) do
              gameplay_missions_progress.generateAttempts(mission.id, 1 + math.floor(math.random()*4))
            end
              if math.random() < 0.5 then
                gameplay_missions_progress.generateAttempts(mission.id, 1 + math.floor(math.random()*4))
              end