{"record":{"id":"d3afbc90dedf5d88","repo":"OpenRA/OpenRA","slug":"cannot-set-timelimit-timelimitmanager-trait-is-mi","errorCode":null,"errorMessage":"Cannot set TimeLimit, TimeLimitManager trait is missing.","messagePattern":"Cannot set TimeLimit, TimeLimitManager trait is missing\\.","errorType":"exception","errorClass":"LuaException","httpStatus":null,"severity":"error","filePath":"OpenRA.Mods.Common/Scripting/Global/DateTimeGlobal.cs","lineNumber":76,"sourceCode":"\t\tpublic int CurrentSecond => DateTime.Now.Second;\n\n\t\t[Desc(\"Converts the number of minutes into game time (ticks).\")]\n\t\tpublic int Minutes(int minutes)\n\t\t{\n\t\t\treturn Seconds(minutes * 60);\n\t\t}\n\n\t\t[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.\")]\n\t\tpublic int TimeLimit\n\t\t{\n\t\t\tget => tlm?.TimeLimit ?? 0;\n\n\t\t\tset\n\t\t\t{\n\t\t\t\tif (tlm != null)\n\t\t\t\t\ttlm.TimeLimit = value == 0 ? 0 : value + GameTime;\n\t\t\t\telse\n\t\t\t\t\tthrow new LuaException(\"Cannot set TimeLimit, TimeLimitManager trait is missing.\");\n\t\t\t}\n\t\t}\n\n\t\t[Desc(\"The notification string used for custom time limit warnings. See the TimeLimitManager trait documentation for details.\")]\n\t\tpublic string TimeLimitNotification\n\t\t{\n\t\t\tget => tlm?.Notification;\n\n\t\t\tset\n\t\t\t{\n\t\t\t\tif (tlm != null)\n\t\t\t\t\ttlm.Notification = value;\n\t\t\t\telse\n\t\t\t\t\tthrow new LuaException(\"Cannot set TimeLimitNotification, TimeLimitManager trait is missing.\");\n\t\t\t}\n\t\t}\n\t}\n}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/OpenRA/OpenRA/blob/a520984d91eda9de48a62b1d15c1e3bad0d4fb1a/OpenRA.Mods.Common/Scripting/Global/DateTimeGlobal.cs#L58-L94","documentation":"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.","triggerScenarios":"Setting DateTime.TimeLimit in a script for a map/world whose world actor does not include the TimeLimitManager trait.","commonSituations":"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.","solutions":["Add the TimeLimitManager trait to the world actor in the map/mod rules.","Only set TimeLimit when the trait is present (read it first; if 0/null, do not set).","If the feature is optional, guard the assignment."],"exampleFix":"-- before\nDateTime.TimeLimit = 15000\n-- after\n-- ensure world actor has TimeLimitManager in rules, then:\nDateTime.TimeLimit = 15000\n-- rules.yaml: World: ... TimeLimitManager:","handlingStrategy":"validation","validationCode":"-- Only set TimeLimit if the world supports it (read first; default is 0 and trait absent).\nif SupportsTimeLimit then\n  DateTime.TimeLimit = ticks\nend","typeGuard":"local function WorldHasTimeLimitManager()\n  return SupportsTimeLimit == true\nend","tryCatchPattern":"local ok = pcall(function() DateTime.TimeLimit = ticks end)\nif not ok then -- world lacks TimeLimitManager; skip end","preventionTips":["Add TimeLimitManager to the world actor when the feature is needed.","Gate time-limit scripts behind a capability check.","Document map prerequisites for time-limit scripts."],"tags":["openra","lua-scripting","time-limit","missing-trait"],"backgroundTag":null,"analyzedSha":"a520984d91eda9de48a62b1d15c1e3bad0d4fb1a","analyzedAt":"2026-08-13T15:30:14.787Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}