We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2430e21 commit ddca8f1Copy full SHA for ddca8f1
HashifyNETCLI/Core/ScriptHelpers.cs
@@ -93,5 +93,28 @@ public static byte[] HexToArray(string hex)
93
94
return bytes;
95
}
96
+
97
+ public static byte[] ToByteArray(NLua.LuaTable table)
98
+ {
99
+ if (table == null)
100
+ throw new ArgumentNullException(nameof(table));
101
102
+ if (table.Values.Count < 1)
103
+ return Array.Empty<byte>();
104
105
+ byte[] result = new byte[table.Values.Count];
106
+ int ndx = 0;
107
+ foreach (var value in table.Values)
108
109
+ if (value is not long && value is not int && value is not byte)
110
+ throw new ArgumentException("Lua table contains non-integer values.");
111
112
+ byte b = Convert.ToByte(value);
113
+ result[ndx] = b;
114
+ ndx++;
115
+ }
116
117
+ return result;
118
119
120
0 commit comments