OpenRA/OpenRA · error · LuaException
Attempted to call WDist.LessThanOrEqualTo(WDist, WDist) with
Error message
Attempted to call WDist.LessThanOrEqualTo(WDist, WDist) with invalid arguments.
What it means
Lua scripting error from the WDist binding's LessThanOrEqualTo operator (`<=`). Requires both operands to be WDist; throws if either fails conversion.
Source
Thrown at OpenRA.Game/WDist.cs:171
{
if (!left.TryGetClrValue(out WDist a) || !right.TryGetClrValue(out int b))
throw new LuaException("Attempted to call WDist.Divide(WDist, integer) with invalid arguments.");
return new LuaCustomClrObject(a / b);
}
public LuaValue LessThan(LuaRuntime runtime, LuaValue left, LuaValue right)
{
if (!left.TryGetClrValue(out WDist a) || !right.TryGetClrValue(out WDist b))
throw new LuaException("Attempted to call WDist.LessThan(WDist, WDist) with invalid arguments.");
return a < b;
}
public LuaValue LessThanOrEqualTo(LuaRuntime runtime, LuaValue left, LuaValue right)
{
if (!left.TryGetClrValue(out WDist a) || !right.TryGetClrValue(out WDist b))
throw new LuaException("Attempted to call WDist.LessThanOrEqualTo(WDist, WDist) with invalid arguments.");
return a <= b;
}
public LuaValue this[LuaRuntime runtime, LuaValue key]
{
get
{
switch (key.ToString())
{
case "Length": return Length;
default: throw new LuaException($"WDist does not define a member '{key}'");
}
}
set => throw new LuaException("WDist is read-only. Use WDist.New to create a new value");
}
View on GitHub (pinned to a520984d91)
Solutions
- Compare WDist to WDist: `wdist <= WDist.New(ceiling)`.
- Or compare raw lengths: `wdist.Length <= 1024`.
- Confirm both operands are WDist.
Example fix
-- before if wdist <= 2048 then end -- after if wdist <= WDist.New(2048) then end
Defensive patterns
Strategy: type-guard
Validate before calling
if a.Length <= b.Length then end
Type guard
local function IsWDist(v)
local ok, clr = pcall(function() return v.Length end)
return ok and clr ~= nil
end Try / catch
if IsWDist(left) and IsWDist(right) then
le = left <= right
else
le = left.Length <= right.Length
end Prevention
- Use `<=` only between two WDist values, or compare .Length ints.
- Construct the threshold as a WDist before comparing.
- Guard dynamic operands with IsWDist.
When it happens
Trigger: A Lua comparison like `wdist <= 1024`, `5 <= wdist`, or `wdist <= otherType` — comparison where left or right is not a WDist.
Common situations: Scripts using `<=` against a raw integer range/ceiling instead of a constructed WDist.
Related errors
- Attempted to call WDist.LessThan(WDist, WDist) with invalid
- Attempted to call WDist.Add(WDist, WDist) with invalid argum
- Attempted to call WDist.Subtract(WDist, WDist) with invalid
- Attempted to call WDist.Equals(WDist, WDist) with invalid ar
- Attempted to call WDist.Multiply(WDist, integer) with invali
AI-assisted analysis of OpenRA/OpenRA@a520984d91 (2026-08-13).
Data as JSON: /api/errors/293fad19afe61c21.
Report an issue: GitHub.