isaacscript-common 10.0.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/isaacscript-common.lua +16 -15
- package/dist/package.lua +1 -1
- package/dist/src/functions/bitSet128.d.ts.map +1 -1
- package/dist/src/functions/bitSet128.lua +2 -2
- package/dist/src/functions/color.d.ts.map +1 -1
- package/dist/src/functions/color.lua +2 -2
- package/dist/src/functions/kColor.d.ts.map +1 -1
- package/dist/src/functions/kColor.lua +2 -2
- package/dist/src/functions/table.d.ts +2 -2
- package/dist/src/functions/table.d.ts.map +1 -1
- package/dist/src/functions/table.lua +6 -5
- package/dist/src/functions/vector.d.ts.map +1 -1
- package/dist/src/functions/vector.lua +2 -2
- package/package.json +1 -1
- package/src/functions/bitSet128.ts +6 -2
- package/src/functions/color.ts +6 -2
- package/src/functions/kColor.ts +6 -2
- package/src/functions/table.ts +8 -5
- package/src/functions/vector.ts +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -950,8 +950,8 @@ export declare function copyRNG(rng: RNG): RNG;
|
|
|
950
950
|
/** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
|
|
951
951
|
export declare function copySet<T>(oldSet: Set<T> | ReadonlySet<T>): Set<T>;
|
|
952
952
|
|
|
953
|
-
/** Helper function to copy specific values from a object to a table. */
|
|
954
|
-
export declare function
|
|
953
|
+
/** Helper function to copy specific values from a userdata object (e.g. `Vector`) to a table. */
|
|
954
|
+
export declare function copyUserdataValuesToTable(object: unknown, keys: string[], luaMap: LuaMap<string, unknown>): void;
|
|
955
955
|
|
|
956
956
|
/** Helper function to copy a `Vector` Isaac API class. */
|
|
957
957
|
export declare function copyVector(vector: Vector): Vector;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 10.0.
|
|
3
|
+
isaacscript-common 10.0.1
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -18407,7 +18407,7 @@ local ____types = require("src.functions.types")
|
|
|
18407
18407
|
local isBoolean = ____types.isBoolean
|
|
18408
18408
|
local isNumber = ____types.isNumber
|
|
18409
18409
|
local isString = ____types.isString
|
|
18410
|
-
local
|
|
18410
|
+
local isUserdata = ____types.isUserdata
|
|
18411
18411
|
--- In a `Map`, you can use the `clear` method to delete every element. However, in a `LuaMap`, the
|
|
18412
18412
|
-- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
|
|
18413
18413
|
function ____exports.clearTable(self, luaMap)
|
|
@@ -18415,13 +18415,14 @@ function ____exports.clearTable(self, luaMap)
|
|
|
18415
18415
|
luaMap[key] = nil
|
|
18416
18416
|
end
|
|
18417
18417
|
end
|
|
18418
|
-
--- Helper function to copy specific values from a object to a table.
|
|
18419
|
-
function ____exports.
|
|
18420
|
-
if not
|
|
18418
|
+
--- Helper function to copy specific values from a userdata object (e.g. `Vector`) to a table.
|
|
18419
|
+
function ____exports.copyUserdataValuesToTable(self, object, keys, luaMap)
|
|
18420
|
+
if not isUserdata(nil, object) then
|
|
18421
18421
|
error("Failed to copy an object values to a table, since the object was of type: " .. type(object))
|
|
18422
18422
|
end
|
|
18423
|
+
local userdata = object
|
|
18423
18424
|
for ____, key in ipairs(keys) do
|
|
18424
|
-
local value =
|
|
18425
|
+
local value = userdata[key]
|
|
18425
18426
|
luaMap[key] = value
|
|
18426
18427
|
end
|
|
18427
18428
|
end
|
|
@@ -20201,7 +20202,7 @@ local getRandomSeed = ____rng.getRandomSeed
|
|
|
20201
20202
|
local isRNG = ____rng.isRNG
|
|
20202
20203
|
local newRNG = ____rng.newRNG
|
|
20203
20204
|
local ____table = require("src.functions.table")
|
|
20204
|
-
local
|
|
20205
|
+
local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
|
|
20205
20206
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
20206
20207
|
local tableHasKeys = ____table.tableHasKeys
|
|
20207
20208
|
local ____types = require("src.functions.types")
|
|
@@ -20275,7 +20276,7 @@ function ____exports.serializeVector(self, vector)
|
|
|
20275
20276
|
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
20276
20277
|
end
|
|
20277
20278
|
local vectorTable = {}
|
|
20278
|
-
|
|
20279
|
+
copyUserdataValuesToTable(nil, vector, KEYS, vectorTable)
|
|
20279
20280
|
vectorTable[SerializationBrand.VECTOR] = ""
|
|
20280
20281
|
return vectorTable
|
|
20281
20282
|
end
|
|
@@ -24919,7 +24920,7 @@ local getRandomSeed = ____rng.getRandomSeed
|
|
|
24919
24920
|
local isRNG = ____rng.isRNG
|
|
24920
24921
|
local newRNG = ____rng.newRNG
|
|
24921
24922
|
local ____table = require("src.functions.table")
|
|
24922
|
-
local
|
|
24923
|
+
local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
|
|
24923
24924
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
24924
24925
|
local tableHasKeys = ____table.tableHasKeys
|
|
24925
24926
|
local ____types = require("src.functions.types")
|
|
@@ -25003,7 +25004,7 @@ function ____exports.serializeKColor(self, kColor)
|
|
|
25003
25004
|
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
25004
25005
|
end
|
|
25005
25006
|
local kColorTable = {}
|
|
25006
|
-
|
|
25007
|
+
copyUserdataValuesToTable(nil, kColor, KEYS, kColorTable)
|
|
25007
25008
|
kColorTable[SerializationBrand.K_COLOR] = ""
|
|
25008
25009
|
return kColorTable
|
|
25009
25010
|
end
|
|
@@ -29639,7 +29640,7 @@ local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
|
29639
29640
|
local ____isaacAPIClass = require("src.functions.isaacAPIClass")
|
|
29640
29641
|
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
29641
29642
|
local ____table = require("src.functions.table")
|
|
29642
|
-
local
|
|
29643
|
+
local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
|
|
29643
29644
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
29644
29645
|
local tableHasKeys = ____table.tableHasKeys
|
|
29645
29646
|
local ____types = require("src.functions.types")
|
|
@@ -29698,7 +29699,7 @@ function ____exports.serializeBitSet128(self, bitSet128)
|
|
|
29698
29699
|
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
29699
29700
|
end
|
|
29700
29701
|
local bitSet128Table = {}
|
|
29701
|
-
|
|
29702
|
+
copyUserdataValuesToTable(nil, bitSet128, KEYS, bitSet128Table)
|
|
29702
29703
|
bitSet128Table[SerializationBrand.BIT_SET_128] = ""
|
|
29703
29704
|
return bitSet128Table
|
|
29704
29705
|
end
|
|
@@ -29719,7 +29720,7 @@ local getRandomSeed = ____rng.getRandomSeed
|
|
|
29719
29720
|
local isRNG = ____rng.isRNG
|
|
29720
29721
|
local newRNG = ____rng.newRNG
|
|
29721
29722
|
local ____table = require("src.functions.table")
|
|
29722
|
-
local
|
|
29723
|
+
local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
|
|
29723
29724
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
29724
29725
|
local tableHasKeys = ____table.tableHasKeys
|
|
29725
29726
|
local ____types = require("src.functions.types")
|
|
@@ -29824,7 +29825,7 @@ function ____exports.serializeColor(self, color)
|
|
|
29824
29825
|
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
29825
29826
|
end
|
|
29826
29827
|
local colorTable = {}
|
|
29827
|
-
|
|
29828
|
+
copyUserdataValuesToTable(nil, color, KEYS, colorTable)
|
|
29828
29829
|
colorTable[SerializationBrand.COLOR] = ""
|
|
29829
29830
|
return colorTable
|
|
29830
29831
|
end
|
|
@@ -46845,7 +46846,7 @@ return ____exports
|
|
|
46845
46846
|
["package"] = function(...)
|
|
46846
46847
|
return {
|
|
46847
46848
|
name = "isaacscript-common",
|
|
46848
|
-
version = "10.0.
|
|
46849
|
+
version = "10.0.1",
|
|
46849
46850
|
description = "Helper functions and features for IsaacScript mods.",
|
|
46850
46851
|
keywords = {"isaac", "rebirth", "afterbirth", "repentance"},
|
|
46851
46852
|
homepage = "https://isaacscript.github.io/",
|
package/dist/package.lua
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitSet128.d.ts","sourceRoot":"","sources":["../../../src/functions/bitSet128.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"bitSet128.d.ts","sourceRoot":"","sources":["../../../src/functions/bitSet128.ts"],"names":[],"mappings":";;AASA,oBAAY,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC1D,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC;CAC7C,CAAC;AAKF,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAW7D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,mBAAmB,GAC7B,SAAS,CAqBX;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,SAAS,CAEhE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,mBAAmB,CAQ/B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,mBAAmB,CAW5E"}
|
|
@@ -5,7 +5,7 @@ local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
|
5
5
|
local ____isaacAPIClass = require("src.functions.isaacAPIClass")
|
|
6
6
|
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
7
7
|
local ____table = require("src.functions.table")
|
|
8
|
-
local
|
|
8
|
+
local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
|
|
9
9
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
10
10
|
local tableHasKeys = ____table.tableHasKeys
|
|
11
11
|
local ____types = require("src.functions.types")
|
|
@@ -64,7 +64,7 @@ function ____exports.serializeBitSet128(self, bitSet128)
|
|
|
64
64
|
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
65
65
|
end
|
|
66
66
|
local bitSet128Table = {}
|
|
67
|
-
|
|
67
|
+
copyUserdataValuesToTable(nil, bitSet128, KEYS, bitSet128Table)
|
|
68
68
|
bitSet128Table[SerializationBrand.BIT_SET_128] = ""
|
|
69
69
|
return bitSet128Table
|
|
70
70
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/functions/color.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/functions/color.ts"],"names":[],"mappings":";;;;AAWA,oBAAY,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACtD,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CACzC,CAAC;AAKF,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,CAEjE;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAgB7C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,CA8B9D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,KAAK,SAAI,GACR,KAAK,CAQP;AAED,+EAA+E;AAC/E,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,KAAK,CAExD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,eAAe,CAM5E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAW5D"}
|
|
@@ -12,7 +12,7 @@ local getRandomSeed = ____rng.getRandomSeed
|
|
|
12
12
|
local isRNG = ____rng.isRNG
|
|
13
13
|
local newRNG = ____rng.newRNG
|
|
14
14
|
local ____table = require("src.functions.table")
|
|
15
|
-
local
|
|
15
|
+
local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
|
|
16
16
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
17
17
|
local tableHasKeys = ____table.tableHasKeys
|
|
18
18
|
local ____types = require("src.functions.types")
|
|
@@ -117,7 +117,7 @@ function ____exports.serializeColor(self, color)
|
|
|
117
117
|
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
118
118
|
end
|
|
119
119
|
local colorTable = {}
|
|
120
|
-
|
|
120
|
+
copyUserdataValuesToTable(nil, color, KEYS, colorTable)
|
|
121
121
|
colorTable[SerializationBrand.COLOR] = ""
|
|
122
122
|
return colorTable
|
|
123
123
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kColor.d.ts","sourceRoot":"","sources":["../../../src/functions/kColor.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"kColor.d.ts","sourceRoot":"","sources":["../../../src/functions/kColor.ts"],"names":[],"mappings":";;;;AAWA,oBAAY,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACvD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;CAC1C,CAAC;AAKF,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CA+BlE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,KAAK,SAAI,GACR,MAAM,CAQR;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,gBAAgB,CAQ5B;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAWhE"}
|
|
@@ -12,7 +12,7 @@ local getRandomSeed = ____rng.getRandomSeed
|
|
|
12
12
|
local isRNG = ____rng.isRNG
|
|
13
13
|
local newRNG = ____rng.newRNG
|
|
14
14
|
local ____table = require("src.functions.table")
|
|
15
|
-
local
|
|
15
|
+
local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
|
|
16
16
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
17
17
|
local tableHasKeys = ____table.tableHasKeys
|
|
18
18
|
local ____types = require("src.functions.types")
|
|
@@ -96,7 +96,7 @@ function ____exports.serializeKColor(self, kColor)
|
|
|
96
96
|
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
97
97
|
end
|
|
98
98
|
local kColorTable = {}
|
|
99
|
-
|
|
99
|
+
copyUserdataValuesToTable(nil, kColor, KEYS, kColorTable)
|
|
100
100
|
kColorTable[SerializationBrand.K_COLOR] = ""
|
|
101
101
|
return kColorTable
|
|
102
102
|
end
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* `clear` method does not exist. Use this helper function as a drop-in replacement for this.
|
|
5
5
|
*/
|
|
6
6
|
export declare function clearTable(luaMap: LuaMap<AnyNotNil, unknown>): void;
|
|
7
|
-
/** Helper function to copy specific values from a object to a table. */
|
|
8
|
-
export declare function
|
|
7
|
+
/** Helper function to copy specific values from a userdata object (e.g. `Vector`) to a table. */
|
|
8
|
+
export declare function copyUserdataValuesToTable(object: unknown, keys: string[], luaMap: LuaMap<string, unknown>): void;
|
|
9
9
|
/**
|
|
10
10
|
* Helper function to safely get boolean values from a Lua table. Will throw an error if the
|
|
11
11
|
* specific value does not exist on the table.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/functions/table.ts"],"names":[],"mappings":";AAEA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,IAAI,CAInE;AAED,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/functions/table.ts"],"names":[],"mappings":";AAEA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,IAAI,CAInE;AAED,iGAAiG;AACjG,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,IAAI,CAgBN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,EAAE,MAAM,EAClB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,OAAO,EAAE,CAoBX;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,EAAE,MAAM,EAClB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,MAAM,EAAE,CA4BV;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,EAAE,MAAM,EAClB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,MAAM,EAAE,CAmBV;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,EACxD,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,EAChC,OAAO,UAAO,GACb,IAAI,CA6BN;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,EAClC,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,OAAO,CAET"}
|
|
@@ -8,7 +8,7 @@ local ____types = require("src.functions.types")
|
|
|
8
8
|
local isBoolean = ____types.isBoolean
|
|
9
9
|
local isNumber = ____types.isNumber
|
|
10
10
|
local isString = ____types.isString
|
|
11
|
-
local
|
|
11
|
+
local isUserdata = ____types.isUserdata
|
|
12
12
|
--- In a `Map`, you can use the `clear` method to delete every element. However, in a `LuaMap`, the
|
|
13
13
|
-- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
|
|
14
14
|
function ____exports.clearTable(self, luaMap)
|
|
@@ -16,13 +16,14 @@ function ____exports.clearTable(self, luaMap)
|
|
|
16
16
|
luaMap[key] = nil
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
|
-
--- Helper function to copy specific values from a object to a table.
|
|
20
|
-
function ____exports.
|
|
21
|
-
if not
|
|
19
|
+
--- Helper function to copy specific values from a userdata object (e.g. `Vector`) to a table.
|
|
20
|
+
function ____exports.copyUserdataValuesToTable(self, object, keys, luaMap)
|
|
21
|
+
if not isUserdata(nil, object) then
|
|
22
22
|
error("Failed to copy an object values to a table, since the object was of type: " .. type(object))
|
|
23
23
|
end
|
|
24
|
+
local userdata = object
|
|
24
25
|
for ____, key in ipairs(keys) do
|
|
25
|
-
local value =
|
|
26
|
+
local value = userdata[key]
|
|
26
27
|
luaMap[key] = value
|
|
27
28
|
end
|
|
28
29
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/functions/vector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/functions/vector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAazD,oBAAY,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACvD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;CAC1C,CAAC;AAKF,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAqBlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,MAAM,CAOR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,gBAAgB,CAM5B;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAWhE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAG3D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,MAAM,CAIpE"}
|
|
@@ -14,7 +14,7 @@ local getRandomSeed = ____rng.getRandomSeed
|
|
|
14
14
|
local isRNG = ____rng.isRNG
|
|
15
15
|
local newRNG = ____rng.newRNG
|
|
16
16
|
local ____table = require("src.functions.table")
|
|
17
|
-
local
|
|
17
|
+
local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
|
|
18
18
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
19
19
|
local tableHasKeys = ____table.tableHasKeys
|
|
20
20
|
local ____types = require("src.functions.types")
|
|
@@ -88,7 +88,7 @@ function ____exports.serializeVector(self, vector)
|
|
|
88
88
|
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
89
89
|
end
|
|
90
90
|
local vectorTable = {}
|
|
91
|
-
|
|
91
|
+
copyUserdataValuesToTable(nil, vector, KEYS, vectorTable)
|
|
92
92
|
vectorTable[SerializationBrand.VECTOR] = ""
|
|
93
93
|
return vectorTable
|
|
94
94
|
end
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
2
2
|
import { isIsaacAPIClassOfType } from "./isaacAPIClass";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
copyUserdataValuesToTable,
|
|
5
|
+
getNumbersFromTable,
|
|
6
|
+
tableHasKeys,
|
|
7
|
+
} from "./table";
|
|
4
8
|
import { isTable } from "./types";
|
|
5
9
|
|
|
6
10
|
export type SerializedBitSet128 = LuaMap<string, unknown> & {
|
|
@@ -86,7 +90,7 @@ export function serializeBitSet128(bitSet128: BitSet128): SerializedBitSet128 {
|
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
const bitSet128Table = new LuaMap<string, unknown>();
|
|
89
|
-
|
|
93
|
+
copyUserdataValuesToTable(bitSet128, KEYS, bitSet128Table);
|
|
90
94
|
bitSet128Table.set(SerializationBrand.BIT_SET_128, "");
|
|
91
95
|
return bitSet128Table as SerializedBitSet128;
|
|
92
96
|
}
|
package/src/functions/color.ts
CHANGED
|
@@ -2,7 +2,11 @@ import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
|
2
2
|
import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
|
|
3
3
|
import { getRandom } from "./random";
|
|
4
4
|
import { getRandomSeed, isRNG, newRNG } from "./rng";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
copyUserdataValuesToTable,
|
|
7
|
+
getNumbersFromTable,
|
|
8
|
+
tableHasKeys,
|
|
9
|
+
} from "./table";
|
|
6
10
|
import { isTable } from "./types";
|
|
7
11
|
|
|
8
12
|
export type SerializedColor = LuaMap<string, unknown> & {
|
|
@@ -120,7 +124,7 @@ export function serializeColor(color: Color): SerializedColor {
|
|
|
120
124
|
}
|
|
121
125
|
|
|
122
126
|
const colorTable = new LuaMap<string, unknown>();
|
|
123
|
-
|
|
127
|
+
copyUserdataValuesToTable(color, KEYS, colorTable);
|
|
124
128
|
colorTable.set(SerializationBrand.COLOR, "");
|
|
125
129
|
return colorTable as SerializedColor;
|
|
126
130
|
}
|
package/src/functions/kColor.ts
CHANGED
|
@@ -2,7 +2,11 @@ import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
|
2
2
|
import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
|
|
3
3
|
import { getRandom } from "./random";
|
|
4
4
|
import { getRandomSeed, isRNG, newRNG } from "./rng";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
copyUserdataValuesToTable,
|
|
7
|
+
getNumbersFromTable,
|
|
8
|
+
tableHasKeys,
|
|
9
|
+
} from "./table";
|
|
6
10
|
import { isTable } from "./types";
|
|
7
11
|
|
|
8
12
|
export type SerializedKColor = LuaMap<string, unknown> & {
|
|
@@ -117,7 +121,7 @@ export function serializeKColor(kColor: KColor): SerializedKColor {
|
|
|
117
121
|
}
|
|
118
122
|
|
|
119
123
|
const kColorTable = new LuaMap<string, unknown>();
|
|
120
|
-
|
|
124
|
+
copyUserdataValuesToTable(kColor, KEYS, kColorTable);
|
|
121
125
|
kColorTable.set(SerializationBrand.K_COLOR, "");
|
|
122
126
|
return kColorTable as SerializedKColor;
|
|
123
127
|
}
|
package/src/functions/table.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBoolean, isNumber, isString,
|
|
1
|
+
import { isBoolean, isNumber, isString, isUserdata } from "./types";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* In a `Map`, you can use the `clear` method to delete every element. However, in a `LuaMap`, the
|
|
@@ -10,13 +10,13 @@ export function clearTable(luaMap: LuaMap<AnyNotNil, unknown>): void {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
/** Helper function to copy specific values from a object to a table. */
|
|
14
|
-
export function
|
|
13
|
+
/** Helper function to copy specific values from a userdata object (e.g. `Vector`) to a table. */
|
|
14
|
+
export function copyUserdataValuesToTable(
|
|
15
15
|
object: unknown,
|
|
16
16
|
keys: string[],
|
|
17
17
|
luaMap: LuaMap<string, unknown>,
|
|
18
18
|
): void {
|
|
19
|
-
if (!
|
|
19
|
+
if (!isUserdata(object)) {
|
|
20
20
|
error(
|
|
21
21
|
`Failed to copy an object values to a table, since the object was of type: ${type(
|
|
22
22
|
object,
|
|
@@ -24,8 +24,11 @@ export function copyValuesToTable(
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// We can access values on userdata objects similar to a normal table.
|
|
28
|
+
const userdata = object as unknown as LuaMap<AnyNotNil, unknown>;
|
|
29
|
+
|
|
27
30
|
for (const key of keys) {
|
|
28
|
-
const value =
|
|
31
|
+
const value = userdata.get(key);
|
|
29
32
|
luaMap.set(key, value);
|
|
30
33
|
}
|
|
31
34
|
}
|
package/src/functions/vector.ts
CHANGED
|
@@ -4,7 +4,11 @@ import { angleToDirection } from "./direction";
|
|
|
4
4
|
import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
|
|
5
5
|
import { getRandomFloat } from "./random";
|
|
6
6
|
import { getRandomSeed, isRNG, newRNG } from "./rng";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
copyUserdataValuesToTable,
|
|
9
|
+
getNumbersFromTable,
|
|
10
|
+
tableHasKeys,
|
|
11
|
+
} from "./table";
|
|
8
12
|
import { isTable } from "./types";
|
|
9
13
|
|
|
10
14
|
export type SerializedVector = LuaMap<string, unknown> & {
|
|
@@ -104,7 +108,7 @@ export function serializeVector(vector: Vector): SerializedVector {
|
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
const vectorTable = new LuaMap<string, unknown>();
|
|
107
|
-
|
|
111
|
+
copyUserdataValuesToTable(vector, KEYS, vectorTable);
|
|
108
112
|
vectorTable.set(SerializationBrand.VECTOR, "");
|
|
109
113
|
return vectorTable as SerializedVector;
|
|
110
114
|
}
|