isaacscript-common 1.2.200 → 1.2.203

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.
Files changed (56) hide show
  1. package/dist/callbacks/customRevive.lua +6 -11
  2. package/dist/callbacks/postNewRoomEarly.lua +3 -5
  3. package/dist/classes/ModUpgraded.d.ts +1 -3
  4. package/dist/classes/ModUpgraded.lua +2 -36
  5. package/dist/constants.d.ts +4 -0
  6. package/dist/constants.lua +2 -0
  7. package/dist/enums/private/SerializationBrand.d.ts +2 -0
  8. package/dist/enums/private/SerializationBrand.lua +2 -0
  9. package/dist/features/deployJSONRoom.d.ts +6 -12
  10. package/dist/features/deployJSONRoom.lua +17 -18
  11. package/dist/features/saveDataManager/load.lua +2 -1
  12. package/dist/features/saveDataManager/main.lua +3 -3
  13. package/dist/features/saveDataManager/merge.d.ts +12 -3
  14. package/dist/features/saveDataManager/merge.lua +16 -11
  15. package/dist/functions/array.d.ts +7 -7
  16. package/dist/functions/array.lua +22 -22
  17. package/dist/functions/cards.d.ts +6 -6
  18. package/dist/functions/cards.lua +14 -12
  19. package/dist/functions/color.d.ts +19 -1
  20. package/dist/functions/color.lua +89 -10
  21. package/dist/functions/deepCopy.d.ts +8 -12
  22. package/dist/functions/deepCopy.lua +13 -29
  23. package/dist/functions/doors.d.ts +4 -0
  24. package/dist/functions/doors.lua +12 -2
  25. package/dist/functions/entity.lua +4 -4
  26. package/dist/functions/jsonHelpers.lua +2 -2
  27. package/dist/functions/jsonRoom.d.ts +1 -1
  28. package/dist/functions/jsonRoom.lua +6 -4
  29. package/dist/functions/log.d.ts +12 -1
  30. package/dist/functions/log.lua +12 -4
  31. package/dist/functions/map.d.ts +0 -12
  32. package/dist/functions/map.lua +0 -23
  33. package/dist/functions/random.d.ts +27 -27
  34. package/dist/functions/random.lua +35 -29
  35. package/dist/functions/revive.lua +7 -0
  36. package/dist/functions/rng.d.ts +44 -0
  37. package/dist/functions/rng.lua +106 -0
  38. package/dist/functions/roomData.d.ts +5 -0
  39. package/dist/functions/roomData.lua +31 -4
  40. package/dist/functions/set.d.ts +2 -2
  41. package/dist/functions/set.lua +6 -4
  42. package/dist/functions/spawnCollectible.d.ts +3 -3
  43. package/dist/functions/spawnCollectible.lua +11 -10
  44. package/dist/functions/table.d.ts +30 -0
  45. package/dist/functions/table.lua +73 -1
  46. package/dist/functions/utils.d.ts +5 -0
  47. package/dist/functions/utils.lua +12 -0
  48. package/dist/functions/vector.d.ts +23 -3
  49. package/dist/functions/vector.lua +72 -21
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.lua +8 -0
  52. package/dist/objects/roomShapeToDoorSlots.d.ts +4 -0
  53. package/dist/objects/roomShapeToDoorSlots.lua +44 -0
  54. package/dist/upgradeMod.d.ts +1 -3
  55. package/dist/upgradeMod.lua +2 -5
  56. package/package.json +2 -2
@@ -1,7 +1,20 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
- export declare function copyVector(vector: Vector): Vector;
4
- export declare function deserializeVector(vectorTable: LuaTable): Vector;
3
+ import { SerializationType } from "../enums/SerializationType";
4
+ declare type SerializedVector = LuaTable<string, string | number>;
5
+ interface CopyVectorReturn {
6
+ [SerializationType.NONE]: Vector;
7
+ [SerializationType.SERIALIZE]: SerializedVector;
8
+ [SerializationType.DESERIALIZE]: Vector;
9
+ }
10
+ /**
11
+ * Helper function to copy a `Vector` object.
12
+ *
13
+ * @param vector The vector to copy. In the case of deserialization, this will actually be a Lua
14
+ * table instead of an instantiated Vector class.
15
+ * @param serializationType Default is `SerializationType.NONE`.
16
+ */
17
+ export declare function copyVector<V extends Vector | SerializedVector, S extends SerializationType>(vector: V, serializationType: S): CopyVectorReturn[S];
5
18
  export declare function directionToVector(direction: Direction): Vector;
6
19
  /**
7
20
  * Helper function to get a new vector of length 1. Using this is safer than using the `Vector.One`
@@ -13,6 +26,13 @@ export declare function getOneVector(): Vector;
13
26
  * variable because the variable can be overwritten or modified.
14
27
  */
15
28
  export declare function getZeroVector(): Vector;
16
- export declare function isVector(object: unknown): boolean;
29
+ /**
30
+ * Used to determine is the given table is a serialized Vector created by the save data manager
31
+ * and/or the `deepCopy` function.
32
+ */
33
+ export declare function isSerializedVector(object: unknown): object is SerializedVector;
34
+ /** Helper function to check if something is an instantiated Vector object. */
35
+ export declare function isVector(object: unknown): object is Vector;
17
36
  /** Helper function for finding out which way a vector is pointing. */
18
37
  export declare function vectorToDirection(vector: Vector): Direction;
38
+ export {};
@@ -1,22 +1,73 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ local OBJECT_NAME
4
+ local ____SerializationBrand = require("enums.private.SerializationBrand")
5
+ local SerializationBrand = ____SerializationBrand.SerializationBrand
6
+ local ____SerializationType = require("enums.SerializationType")
7
+ local SerializationType = ____SerializationType.SerializationType
3
8
  local ____directionToVector = require("objects.directionToVector")
4
9
  local DIRECTION_TO_VECTOR = ____directionToVector.DIRECTION_TO_VECTOR
5
- function ____exports.copyVector(self, vector)
6
- return Vector(vector.X, vector.Y)
10
+ local ____table = require("functions.table")
11
+ local copyValuesToTable = ____table.copyValuesToTable
12
+ local getNumbersFromTable = ____table.getNumbersFromTable
13
+ local tableHasKeys = ____table.tableHasKeys
14
+ local ____utils = require("functions.utils")
15
+ local ensureAllCases = ____utils.ensureAllCases
16
+ local isUserdataObject = ____utils.isUserdataObject
17
+ function ____exports.isVector(self, object)
18
+ return isUserdataObject(nil, object, OBJECT_NAME)
7
19
  end
8
- function ____exports.deserializeVector(self, vectorTable)
9
- local xString = vectorTable.X
10
- local x = tonumber(xString)
11
- if x == nil then
12
- error("Failed to read the X value of a serialized vector.")
13
- end
14
- local yString = vectorTable.Y
15
- local y = tonumber(yString)
16
- if y == nil then
17
- error("Failed to read the Y value of a serialized vector.")
20
+ local KEYS = {"X", "Y"}
21
+ OBJECT_NAME = "Vector"
22
+ function ____exports.copyVector(self, vector, serializationType)
23
+ if serializationType == nil then
24
+ serializationType = SerializationType.NONE
18
25
  end
19
- return Vector(x, y)
26
+ repeat
27
+ local ____switch3 = serializationType
28
+ local ____cond3 = ____switch3 == SerializationType.NONE
29
+ if ____cond3 then
30
+ do
31
+ if not ____exports.isVector(nil, vector) then
32
+ error(((("Failed to copy a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
33
+ end
34
+ return Vector(vector.X, vector.Y)
35
+ end
36
+ end
37
+ ____cond3 = ____cond3 or ____switch3 == SerializationType.SERIALIZE
38
+ if ____cond3 then
39
+ do
40
+ if not ____exports.isVector(nil, vector) then
41
+ error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
42
+ end
43
+ local vectorTable = {}
44
+ copyValuesToTable(nil, vector, KEYS, vectorTable)
45
+ vectorTable[SerializationBrand.VECTOR] = ""
46
+ return vectorTable
47
+ end
48
+ end
49
+ ____cond3 = ____cond3 or ____switch3 == SerializationType.DESERIALIZE
50
+ if ____cond3 then
51
+ do
52
+ local vectorType = type(vector)
53
+ if ____exports.isVector(nil, vector) or vectorType ~= "table" then
54
+ error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
55
+ end
56
+ local x, y = table.unpack(getNumbersFromTable(
57
+ nil,
58
+ vector,
59
+ OBJECT_NAME,
60
+ table.unpack(KEYS)
61
+ ))
62
+ return Vector(x, y)
63
+ end
64
+ end
65
+ do
66
+ do
67
+ return ensureAllCases(nil, serializationType)
68
+ end
69
+ end
70
+ until true
20
71
  end
21
72
  function ____exports.directionToVector(self, direction)
22
73
  return DIRECTION_TO_VECTOR[direction]
@@ -27,17 +78,17 @@ end
27
78
  function ____exports.getZeroVector(self)
28
79
  return Vector(0, 0)
29
80
  end
30
- function ____exports.isVector(self, object)
81
+ function ____exports.isSerializedVector(self, object)
31
82
  local objectType = type(object)
32
- if objectType ~= "userdata" then
33
- return false
34
- end
35
- local metatable = getmetatable(object)
36
- if metatable == nil then
83
+ if objectType ~= "table" then
37
84
  return false
38
85
  end
39
- local vectorMetatable = metatable
40
- return vectorMetatable.__type == "Vector"
86
+ local ____table = object
87
+ return tableHasKeys(
88
+ nil,
89
+ ____table,
90
+ table.unpack(KEYS)
91
+ ) and ____table[SerializationBrand.VECTOR] ~= nil
41
92
  end
42
93
  function ____exports.vectorToDirection(self, vector)
43
94
  local degrees = vector:GetAngleDegrees()
package/dist/index.d.ts CHANGED
@@ -69,6 +69,7 @@ export * from "./functions/pocketItems";
69
69
  export * from "./functions/positionVelocity";
70
70
  export * from "./functions/random";
71
71
  export * from "./functions/revive";
72
+ export * from "./functions/rng";
72
73
  export * from "./functions/roomData";
73
74
  export * from "./functions/rooms";
74
75
  export * from "./functions/run";
package/dist/index.lua CHANGED
@@ -552,6 +552,14 @@ do
552
552
  end
553
553
  end
554
554
  end
555
+ do
556
+ local ____export = require("functions.rng")
557
+ for ____exportKey, ____exportValue in pairs(____export) do
558
+ if ____exportKey ~= "default" then
559
+ ____exports[____exportKey] = ____exportValue
560
+ end
561
+ end
562
+ end
555
563
  do
556
564
  local ____export = require("functions.roomData")
557
565
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -0,0 +1,4 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare const ROOM_SHAPE_TO_DOOR_SLOTS: {
3
+ readonly [key in RoomShape]: ReadonlySet<DoorSlot> | undefined;
4
+ };
@@ -0,0 +1,44 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ local ALL_DOOR_SLOTS_SET = __TS__New(Set, {
6
+ DoorSlot.LEFT0,
7
+ DoorSlot.UP0,
8
+ DoorSlot.RIGHT0,
9
+ DoorSlot.DOWN0,
10
+ DoorSlot.LEFT1,
11
+ DoorSlot.UP1,
12
+ DoorSlot.RIGHT1,
13
+ DoorSlot.DOWN1
14
+ })
15
+ ____exports.ROOM_SHAPE_TO_DOOR_SLOTS = {
16
+ [RoomShape.ROOMSHAPE_1x1] = __TS__New(Set, {DoorSlot.LEFT0, DoorSlot.UP0, DoorSlot.RIGHT0, DoorSlot.DOWN0}),
17
+ [RoomShape.ROOMSHAPE_IH] = __TS__New(Set, {DoorSlot.LEFT0, DoorSlot.RIGHT0}),
18
+ [RoomShape.ROOMSHAPE_IV] = __TS__New(Set, {DoorSlot.UP0, DoorSlot.DOWN0}),
19
+ [RoomShape.ROOMSHAPE_1x2] = __TS__New(Set, {
20
+ DoorSlot.LEFT0,
21
+ DoorSlot.UP0,
22
+ DoorSlot.RIGHT0,
23
+ DoorSlot.DOWN0,
24
+ DoorSlot.LEFT1,
25
+ DoorSlot.RIGHT1
26
+ }),
27
+ [RoomShape.ROOMSHAPE_IIV] = __TS__New(Set, {DoorSlot.UP0, DoorSlot.DOWN0}),
28
+ [RoomShape.ROOMSHAPE_2x1] = __TS__New(Set, {
29
+ DoorSlot.LEFT0,
30
+ DoorSlot.UP0,
31
+ DoorSlot.RIGHT0,
32
+ DoorSlot.DOWN0,
33
+ DoorSlot.UP1,
34
+ DoorSlot.DOWN1
35
+ }),
36
+ [RoomShape.ROOMSHAPE_IIH] = __TS__New(Set, {DoorSlot.LEFT0, DoorSlot.RIGHT0}),
37
+ [RoomShape.ROOMSHAPE_2x2] = ALL_DOOR_SLOTS_SET,
38
+ [RoomShape.ROOMSHAPE_LTL] = ALL_DOOR_SLOTS_SET,
39
+ [RoomShape.ROOMSHAPE_LTR] = ALL_DOOR_SLOTS_SET,
40
+ [RoomShape.ROOMSHAPE_LBL] = ALL_DOOR_SLOTS_SET,
41
+ [RoomShape.ROOMSHAPE_LBR] = ALL_DOOR_SLOTS_SET,
42
+ [RoomShape.NUM_ROOMSHAPES] = nil
43
+ }
44
+ return ____exports
@@ -19,8 +19,6 @@ import { ModUpgraded } from "./classes/ModUpgraded";
19
19
  * [Function Signatures](https://isaacscript.github.io/docs/function-signatures#custom-callbacks).
20
20
  *
21
21
  * @param modVanilla The mod object returned by the `RegisterMod` function.
22
- * @param verbose Enables verbose logging for the purposes of crash troubleshooting.
23
- * Defaults to false.
24
22
  * @returns The upgraded mod object.
25
23
  */
26
- export declare function upgradeMod(modVanilla: Mod, verbose?: boolean): ModUpgraded;
24
+ export declare function upgradeMod(modVanilla: Mod): ModUpgraded;
@@ -167,12 +167,9 @@ function initFeatures(self, mod)
167
167
  fadeInRemoverInit(nil, mod)
168
168
  characterStatsInit(nil, mod)
169
169
  end
170
- function ____exports.upgradeMod(self, modVanilla, verbose)
171
- if verbose == nil then
172
- verbose = false
173
- end
170
+ function ____exports.upgradeMod(self, modVanilla)
174
171
  patchErrorFunction(nil)
175
- local mod = __TS__New(ModUpgraded, modVanilla, verbose)
172
+ local mod = __TS__New(ModUpgraded, modVanilla)
176
173
  if not areFeaturesInitialized(nil) then
177
174
  setFeaturesInitialized(nil)
178
175
  postNewRoomEarlyCallbackInit(nil, mod)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.200",
3
+ "version": "1.2.203",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,7 +25,7 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.377",
28
+ "isaac-typescript-definitions": "^1.0.379",
29
29
  "isaacscript-lint": "^1.0.95",
30
30
  "isaacscript-tsconfig": "^1.1.8",
31
31
  "typedoc": "^0.22.13",