GE Lua Documentation

Press F to search!

onFreeroamConfiguratorGetOptions

Definition


-- @/lua/ge/extensions/freeroam/configuratorOptions/freeroamOptions.lua:3
local function onFreeroamConfiguratorGetOptions(level, options)
  -- Traffic options
  if level.supportsTraffic then
    local trafficGroup = {
      order = 100,
      options = {
        {
          label = translate("ui.apps.traffic.name"),
          icon = "trafficLight",
          value = "enabled", -- Default value, will be overridden by current configuration
          key = "traffic_trafficMode",
          type = "select",
          options = {
            { label = translate("ui.common.disabled"), value = "disabled" },
            { label = translate("ui.apps.traffic.parkedOnly"), value = "parkedOnly", style="active" },
            { label = translate("ui.apps.traffic.normal"), value = "enabled", style="active" },
            { label = translate("ui.apps.traffic.police"), value = "police", style="active" },
          },
        }
      }
    }
    table.insert(options, trafficGroup)
  else
    table.insert(options, {
      order = 100,
      options = {
        {
          label = translate("ui.apps.traffic.notSupported"),
          icon = "trafficLight",
          disabled = true,
        }
      }
    })
  end

  -- Time of day options
  local timeOfDayOptions = core_levels.getTimeOfDayOptions(level.levelName)
  if timeOfDayOptions and #timeOfDayOptions > 0 then
    local timeOfDayGroup = {
      order = 200,
      options = {}
    }

    -- Time option
    local timeOption = {
      label = translate("ui.environment.timeOfDay"),
      value = "default", -- Default value, will be overridden by current configuration
      key = "environment_timeOfDay",
      icon = "weather",
      type = "select",
      options = {
        { label = translate("ui.common.default"), value = "default" },
      },
    }

    for _, option in ipairs(timeOfDayOptions) do
      table.insert(timeOption.options, { label = translate(option.label), value = option.key, style = "active" })
    end

    table.insert(timeOfDayGroup.options, timeOption)

    -- Play option
    local playOption = {
      label = translate("ui.environment.timeOfDayPlay"),
      value = "disabled", -- Default value, will be overridden by current configuration
      key = "environment_timePlay",
      icon = "weather",
      type = "select",
      options = {
        { label = translate("ui.common.disabled"), value = "disabled" },
        { label = translate("engine.editor.menu.cameraspeed.slow"), value = "slow", style="active" },
        { label = translate("engine.editor.menu.cameraspeed.normal"), value = "normal", style="active" },
        { label = translate("engine.editor.menu.cameraspeed.fast"), value = "fast", style="active" },
      },
    }

    table.insert(timeOfDayGroup.options, playOption)
    table.insert(options, timeOfDayGroup)
  else
    table.insert(options, {
      order = 200,
      options = {
        {
          label = translate("ui.environment.timeOfDay.notSupported"),
          icon = "weather",
          disabled = true,
        }
      }
    })
  end
end

Callers