diff --git a/src/BizHawk.Client.Common/lua/LuaDocumentation.cs b/src/BizHawk.Client.Common/lua/LuaDocumentation.cs index 9392975901..819a39d980 100644 --- a/src/BizHawk.Client.Common/lua/LuaDocumentation.cs +++ b/src/BizHawk.Client.Common/lua/LuaDocumentation.cs @@ -33,7 +33,7 @@ namespace BizHawk.Client.Common * luacolor ** Any of: ** a 32-bit number in the format 0xAARRGGBB; -** a string in the format ""#AARRGGBB""; +** a string in the format ""#RRGGBB"" or ""#AARRGGBB""; ** a string containing a CSS3/X11 color name e.g. ""blue"", ""palegoldenrod""; or ** a Color created with forms.createcolor. ** As noted above, luacolor? indicates nil may also be passed. diff --git a/src/BizHawk.Client.Common/lua/NLuaTableHelper.cs b/src/BizHawk.Client.Common/lua/NLuaTableHelper.cs index 0f3be7db1e..d066f5006b 100644 --- a/src/BizHawk.Client.Common/lua/NLuaTableHelper.cs +++ b/src/BizHawk.Client.Common/lua/NLuaTableHelper.cs @@ -86,7 +86,12 @@ namespace BizHawk.Client.Common case int i: return Color.FromArgb(i); case string s: - if (s[0] == '#' && s.Length == 9) return ParseColor(int.Parse(s.Substring(1), NumberStyles.HexNumber), safe, logCallback); + if (s[0] is '#' && (s.Length is 7 or 9)) + { + var i1 = uint.Parse(s.Substring(1), NumberStyles.HexNumber); + if (s.Length is 7) i1 |= 0xFF000000U; + return ParseColor(unchecked((int) i1), safe, logCallback); + } var fromName = Color.FromName(s); if (fromName.IsNamedColor) return fromName; if (safe) logCallback($"ParseColor: not a known color name (\"{s}\")");