GE Lua Documentation

Press F to search!

startCrawl

Definition


-- @/lua/ge/extensions/gameplay/crawl/utils.lua:710

local function startCrawl(crawlerId, trail, crawlerData, isFromMission)
  if not crawlerId or not trail then
    log('E', logTag, 'Invalid parameters for startCrawl')
    return false
  end

  local state = {
    active = true,
    trail = trail,
    crawlerData = crawlerData,
    currentPathnodeIndex = 1,
    completedPathnodes = {},
    skippedPathnodes = {}, -- Track nodes that were skipped
    pathnodeTimings = {},
    eventLog = {},
    currentTime = 0,
    isCompleted = false,
    completionStartTime = 0,
    events = {},
    crawlStarted = true,
    lastRecoveryCheckpoint = nil,
    lastRecoveryCheckpointIndex = 0,
    isDisqualified = false,
    recoveryCount = 0,
    isFromMission = isFromMission or false,
    raceData = nil, -- Race data structure for lap times app
    pendingTeleportCheck = false, -- Flag to check for teleport in next frame
    teleportCheckPos = nil -- Position to check against for teleport detection
  }

  crawlStates[crawlerId] = state

  local path = gameplay_crawl_general.activeTrail and gameplay_crawl_general.activeTrail.path

  if path and path.nodes and #path.nodes > 0 then
    setupCrawlMarkers(path)
    activateCrawlMarkers()

    gameplay_crawl_display.showStartedCrawlMessage()
    gameplay_crawl_display.showPointsMessage(crawlerData.points or 0)
    state.events.crawlStarted = true

    -- Initialize lap times system and create race data structure
    if core_lapTimes then
      local path = gameplay_crawl_general.activeTrail and gameplay_crawl_general.activeTrail.path
      if path and path.nodes then
        core_lapTimes.setConfiguration({
          totalLaps = 1,
          totalSegments = #path.nodes,
          closedCircuit = false
        })
        core_lapTimes.onRaceStart({
          totalLaps = 1,
          totalSegments = #path.nodes,
          pathConfig = { isClosed = false }
        })
        -- Create race data structure once
        state.raceData = createRaceDataStructure(crawlerId, state, path)
      end
    end

    return true
  else
    log('E', logTag, 'No valid path for trail')
    return false
  end
end

Callers

@/lua/ge/extensions/flowgraph/nodes/gameplay/crawl/startCrawl.lua

  log('D', 'StartCrawl', 'Calling bridge.startCrawl (trail and vehicle from Setup Crawl)')
  if self.bridge.startCrawl(nil, nil) then
  log('D', 'StartCrawl', 'Calling bridge.startCrawl (trail and vehicle from Setup Crawl)')
  if self.bridge.startCrawl(nil, nil) then
    log('I', 'StartCrawl', 'Crawl started successfully via bridge')
@/lua/ge/extensions/gameplay/crawl/crawlFlowgraphBridge.lua

  gameplay_crawl_general.startCrawl(bridgeState.activeTrail.trail, veh)
@/lua/ge/extensions/gameplay/crawl/general.lua

  if gameplay_crawl_utils.startCrawl(veh:getID(), trail, crawlerData, false) then
    extensions.hook('onCrawlStarted')

    if gameplay_crawl_utils.startCrawl(veh:getID(), trail, crawlerData, true) then
      extensions.hook('onCrawlStarted')

  if gameplay_crawl_utils.startCrawl(veh:getID(), trail, crawlerData, true) then
    extensions.hook('onCrawlStarted')