OpenRA/OpenRA · error · LuaException

Cannot set TimeLimit, TimeLimitManager trait is missing.

Error message

Cannot set TimeLimit, TimeLimitManager trait is missing.

What it means

DateTimeGlobal caches a TimeLimitManager trait reference (tlm) from the world actor at construction. Setting DateTime.TimeLimit writes through tlm; if the world actor lacks the TimeLimitManager trait, tlm is null and the set is refused.

Source

Thrown at OpenRA.Mods.Common/Scripting/Global/DateTimeGlobal.cs:76

		public int CurrentSecond => DateTime.Now.Second;

		[Desc("Converts the number of minutes into game time (ticks).")]
		public int Minutes(int minutes)
		{
			return Seconds(minutes * 60);
		}

		[Desc("Return or set the time limit (in ticks). When setting, the time limit will count from now. Setting the time limit to 0 will disable it.")]
		public int TimeLimit
		{
			get => tlm?.TimeLimit ?? 0;

			set
			{
				if (tlm != null)
					tlm.TimeLimit = value == 0 ? 0 : value + GameTime;
				else
					throw new LuaException("Cannot set TimeLimit, TimeLimitManager trait is missing.");
			}
		}

		[Desc("The notification string used for custom time limit warnings. See the TimeLimitManager trait documentation for details.")]
		public string TimeLimitNotification
		{
			get => tlm?.Notification;

			set
			{
				if (tlm != null)
					tlm.Notification = value;
				else
					throw new LuaException("Cannot set TimeLimitNotification, TimeLimitManager trait is missing.");
			}
		}
	}
}

View on GitHub (pinned to a520984d91)

Solutions

  1. Add the TimeLimitManager trait to the world actor in the map/mod rules.
  2. Only set TimeLimit when the trait is present (read it first; if 0/null, do not set).
  3. If the feature is optional, guard the assignment.

Example fix

-- before
DateTime.TimeLimit = 15000
-- after
-- ensure world actor has TimeLimitManager in rules, then:
DateTime.TimeLimit = 15000
-- rules.yaml: World: ... TimeLimitManager:
Defensive patterns

Strategy: validation

Validate before calling

-- Only set TimeLimit if the world supports it (read first; default is 0 and trait absent).
if SupportsTimeLimit then
  DateTime.TimeLimit = ticks
end

Type guard

local function WorldHasTimeLimitManager()
  return SupportsTimeLimit == true
end

Try / catch

local ok = pcall(function() DateTime.TimeLimit = ticks end)
if not ok then -- world lacks TimeLimitManager; skip end

Prevention

When it happens

Trigger: Setting DateTime.TimeLimit in a script for a map/world whose world actor does not include the TimeLimitManager trait.

Common situations: Skirmish/mission map without TimeLimitManager configured; custom mod world actor that omits the trait; trying to set a time limit in a gamemode that doesn't support it.

Related errors


AI-assisted analysis of OpenRA/OpenRA@a520984d91 (2026-08-13). Data as JSON: /api/errors/d3afbc90dedf5d88. Report an issue: GitHub.