isaacscript-common 6.9.0 → 6.10.0

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 (118) hide show
  1. package/dist/features/customStage/customStageGridEntities.lua +2 -2
  2. package/dist/features/customStage/exports.d.ts.map +1 -1
  3. package/dist/features/customStage/exports.lua +5 -4
  4. package/dist/features/customStage/init.d.ts.map +1 -1
  5. package/dist/features/customStage/init.lua +12 -3
  6. package/dist/features/customStage/streakText.d.ts +4 -2
  7. package/dist/features/customStage/streakText.d.ts.map +1 -1
  8. package/dist/features/customStage/streakText.lua +216 -15
  9. package/dist/features/customStage/v.d.ts +4 -2
  10. package/dist/features/customStage/v.d.ts.map +1 -1
  11. package/dist/features/customStage/v.lua +9 -1
  12. package/dist/features/customStage/versusScreen.d.ts +1 -1
  13. package/dist/features/customStage/versusScreen.d.ts.map +1 -1
  14. package/dist/features/customStage/versusScreen.lua +2 -5
  15. package/dist/features/extraConsoleCommands/init.lua +1 -0
  16. package/dist/features/extraConsoleCommands/listCommands.d.ts +8 -0
  17. package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
  18. package/dist/features/extraConsoleCommands/listCommands.lua +13 -0
  19. package/dist/features/saveDataManager/exports.d.ts.map +1 -1
  20. package/dist/features/saveDataManager/exports.lua +2 -4
  21. package/dist/features/saveDataManager/load.d.ts +1 -1
  22. package/dist/features/saveDataManager/load.d.ts.map +1 -1
  23. package/dist/features/saveDataManager/main.d.ts.map +1 -1
  24. package/dist/features/saveDataManager/main.lua +0 -1
  25. package/dist/features/saveDataManager/maps.d.ts +3 -3
  26. package/dist/features/saveDataManager/maps.d.ts.map +1 -1
  27. package/dist/features/saveDataManager/maps.lua +1 -4
  28. package/dist/features/saveDataManager/merge.d.ts +2 -2
  29. package/dist/features/saveDataManager/merge.d.ts.map +1 -1
  30. package/dist/features/saveDataManager/merge.lua +3 -3
  31. package/dist/features/saveDataManager/save.d.ts +1 -1
  32. package/dist/features/saveDataManager/save.d.ts.map +1 -1
  33. package/dist/features/saveDataManager/save.lua +1 -2
  34. package/dist/features/saveDataManager/{serializationBrand.d.ts → serializationBrands.d.ts} +1 -1
  35. package/dist/features/saveDataManager/serializationBrands.d.ts.map +1 -0
  36. package/dist/features/saveDataManager/{serializationBrand.lua → serializationBrands.lua} +0 -0
  37. package/dist/functions/array.d.ts.map +1 -1
  38. package/dist/functions/color.d.ts +1 -1
  39. package/dist/functions/color.d.ts.map +1 -1
  40. package/dist/functions/deepCopy.d.ts +1 -1
  41. package/dist/functions/deepCopy.lua +27 -27
  42. package/dist/functions/deepCopyTests.lua +3 -3
  43. package/dist/functions/entities.d.ts +1 -1
  44. package/dist/functions/entities.d.ts.map +1 -1
  45. package/dist/functions/input.d.ts.map +1 -1
  46. package/dist/functions/input.lua +8 -10
  47. package/dist/functions/jsonHelpers.d.ts +1 -1
  48. package/dist/functions/jsonHelpers.d.ts.map +1 -1
  49. package/dist/functions/kColor.d.ts +1 -1
  50. package/dist/functions/kColor.d.ts.map +1 -1
  51. package/dist/functions/log.d.ts +1 -1
  52. package/dist/functions/log.d.ts.map +1 -1
  53. package/dist/functions/log.lua +3 -1
  54. package/dist/functions/mergeTests.d.ts +2 -2
  55. package/dist/functions/mergeTests.lua +2 -2
  56. package/dist/functions/playerIndex.d.ts +1 -1
  57. package/dist/functions/playerIndex.lua +1 -1
  58. package/dist/functions/rng.d.ts +1 -1
  59. package/dist/functions/rng.d.ts.map +1 -1
  60. package/dist/functions/table.d.ts +9 -9
  61. package/dist/functions/table.d.ts.map +1 -1
  62. package/dist/functions/table.lua +23 -21
  63. package/dist/functions/types.d.ts +1 -1
  64. package/dist/functions/types.d.ts.map +1 -1
  65. package/dist/functions/vector.d.ts +1 -1
  66. package/dist/functions/vector.d.ts.map +1 -1
  67. package/dist/interfaces/SaveData.d.ts +1 -1
  68. package/dist/interfaces/private/TSTLClassMetatable.d.ts +1 -1
  69. package/dist/interfaces/private/TSTLClassMetatable.d.ts.map +1 -1
  70. package/dist/lualib_bundle.lua +38 -7
  71. package/dist/types/PlayerIndex.d.ts +3 -2
  72. package/dist/types/PlayerIndex.d.ts.map +1 -1
  73. package/dist/types/private/IsaacAPIClass.d.ts +1 -1
  74. package/dist/types/private/IsaacAPIClass.d.ts.map +1 -1
  75. package/dist/types/private/SerializedIsaacAPIClass.d.ts +1 -1
  76. package/dist/types/private/SerializedIsaacAPIClass.d.ts.map +1 -1
  77. package/dist/types/private/TSTLClass.d.ts +1 -1
  78. package/dist/types/private/TSTLClass.d.ts.map +1 -1
  79. package/package.json +2 -2
  80. package/src/features/customStage/customStageGridEntities.ts +4 -4
  81. package/src/features/customStage/exports.ts +5 -3
  82. package/src/features/customStage/init.ts +19 -7
  83. package/src/features/customStage/streakText.ts +284 -19
  84. package/src/features/customStage/v.ts +6 -1
  85. package/src/features/customStage/versusScreen.ts +2 -5
  86. package/src/features/extraConsoleCommands/init.ts +1 -0
  87. package/src/features/extraConsoleCommands/listCommands.ts +14 -0
  88. package/src/features/saveDataManager/exports.ts +3 -8
  89. package/src/features/saveDataManager/load.ts +2 -3
  90. package/src/features/saveDataManager/main.ts +4 -5
  91. package/src/features/saveDataManager/maps.ts +3 -3
  92. package/src/features/saveDataManager/merge.ts +11 -11
  93. package/src/features/saveDataManager/save.ts +6 -6
  94. package/src/features/saveDataManager/{serializationBrand.ts → serializationBrands.ts} +0 -0
  95. package/src/functions/array.ts +2 -4
  96. package/src/functions/color.ts +3 -3
  97. package/src/functions/deepCopy.ts +39 -36
  98. package/src/functions/deepCopyTests.ts +11 -11
  99. package/src/functions/entities.ts +7 -7
  100. package/src/functions/input.ts +7 -8
  101. package/src/functions/isaacAPIClass.ts +3 -3
  102. package/src/functions/jsonHelpers.ts +3 -3
  103. package/src/functions/kColor.ts +3 -3
  104. package/src/functions/log.ts +5 -4
  105. package/src/functions/mergeTests.ts +24 -24
  106. package/src/functions/playerIndex.ts +1 -1
  107. package/src/functions/rng.ts +3 -3
  108. package/src/functions/table.ts +25 -23
  109. package/src/functions/tstlClass.ts +1 -1
  110. package/src/functions/types.ts +3 -1
  111. package/src/functions/vector.ts +3 -3
  112. package/src/interfaces/SaveData.ts +1 -1
  113. package/src/interfaces/private/TSTLClassMetatable.ts +1 -1
  114. package/src/types/PlayerIndex.ts +3 -2
  115. package/src/types/private/IsaacAPIClass.ts +1 -1
  116. package/src/types/private/SerializedIsaacAPIClass.ts +1 -1
  117. package/src/types/private/TSTLClass.ts +1 -1
  118. package/dist/features/saveDataManager/serializationBrand.d.ts.map +0 -1
@@ -5,7 +5,7 @@ import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
5
5
  import { getNumbersFromTable, tableHasKeys } from "./table";
6
6
  import { isTable } from "./types";
7
7
 
8
- type SerializedRNG = LuaTable<string, unknown> & {
8
+ type SerializedRNG = LuaMap<string, unknown> & {
9
9
  readonly __serializedRNGBrand: symbol;
10
10
  };
11
11
 
@@ -63,7 +63,7 @@ export function copyRNG(
63
63
  }
64
64
 
65
65
  const seed = rng.GetSeed();
66
- const rngTable = new LuaTable<string, unknown>();
66
+ const rngTable = new LuaMap<string, unknown>();
67
67
  rngTable.set("seed", seed);
68
68
  rngTable.set(SerializationBrand.RNG, "");
69
69
  return rngTable as SerializedRNG;
@@ -77,7 +77,7 @@ export function copyRNG(
77
77
  }
78
78
 
79
79
  const [seedNumber] = getNumbersFromTable(
80
- rng as LuaTable<string, unknown>,
80
+ rng as LuaMap<string, unknown>,
81
81
  OBJECT_NAME,
82
82
  ...KEYS,
83
83
  );
@@ -1,12 +1,12 @@
1
1
  import { isBoolean, isNumber, isString } from "./types";
2
2
 
3
3
  /**
4
- * In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
4
+ * In a `Map`, you can use the `clear` method to delete every element. However, in a `LuaMap`, the
5
5
  * `clear` method does not exist. Use this helper function as a drop-in replacement for this.
6
6
  */
7
- export function clearTable(luaTable: LuaTable): void {
8
- for (const [key] of pairs(luaTable)) {
9
- luaTable.delete(key);
7
+ export function clearTable(luaMap: LuaMap): void {
8
+ for (const [key] of pairs(luaMap)) {
9
+ luaMap.delete(key);
10
10
  }
11
11
  }
12
12
 
@@ -14,13 +14,13 @@ export function clearTable(luaTable: LuaTable): void {
14
14
  export function copyValuesToTable(
15
15
  object: unknown,
16
16
  keys: string[],
17
- luaTable: LuaTable<string, unknown>,
17
+ luaMap: LuaMap<string, unknown>,
18
18
  ): void {
19
- const otherTable = object as LuaTable<string, string | number>;
19
+ const otherTable = object as LuaMap<string, string | number>;
20
20
 
21
21
  for (const key of keys) {
22
22
  const value = otherTable.get(key);
23
- luaTable.set(key, value);
23
+ luaMap.set(key, value);
24
24
  }
25
25
  }
26
26
 
@@ -31,13 +31,13 @@ export function copyValuesToTable(
31
31
  * This function is variadic, meaning that you can specify N arguments to get N values.
32
32
  */
33
33
  export function getBooleansFromTable(
34
- luaTable: LuaTable<string, unknown>,
34
+ luaMap: LuaMap<string, unknown>,
35
35
  objectName: string,
36
36
  ...keys: string[]
37
37
  ): boolean[] {
38
38
  const booleans: boolean[] = [];
39
39
  for (const key of keys) {
40
- const value = luaTable.get(key);
40
+ const value = luaMap.get(key);
41
41
  if (value === undefined) {
42
42
  error(
43
43
  `Failed to find a value for "${key}" in a table representing a "${objectName}" object.`,
@@ -63,13 +63,13 @@ export function getBooleansFromTable(
63
63
  * This function is variadic, meaning that you can specify N arguments to get N values.
64
64
  */
65
65
  export function getNumbersFromTable(
66
- luaTable: LuaTable<string, unknown>,
66
+ luaMap: LuaMap<string, unknown>,
67
67
  objectName: string,
68
68
  ...keys: string[]
69
69
  ): number[] {
70
70
  const numbers: number[] = [];
71
71
  for (const key of keys) {
72
- const value = luaTable.get(key);
72
+ const value = luaMap.get(key);
73
73
  if (value === undefined) {
74
74
  error(
75
75
  `Failed to find a value for "${key}" in a table representing a "${objectName}" object.`,
@@ -103,13 +103,13 @@ export function getNumbersFromTable(
103
103
  * This function is variadic, meaning that you can specify N arguments to get N values.
104
104
  */
105
105
  export function getStringsFromTable(
106
- luaTable: LuaTable<string, unknown>,
106
+ luaMap: LuaMap<string, unknown>,
107
107
  objectName: string,
108
108
  ...keys: string[]
109
109
  ): string[] {
110
110
  const strings: string[] = [];
111
111
  for (const key of keys) {
112
- const value = luaTable.get(key);
112
+ const value = luaMap.get(key);
113
113
  if (value === undefined) {
114
114
  error(
115
115
  `Failed to find a value for "${key}" in a table representing a "${objectName}" object.`,
@@ -136,42 +136,44 @@ export function getStringsFromTable(
136
136
  * This function will only work on tables that have number keys or string keys. It will throw a
137
137
  * run-time error if it encounters a key of another type.
138
138
  *
139
- * @param luaTable The table to iterate over.
139
+ * @param luaMap The table to iterate over.
140
140
  * @param func The function to run for each iteration.
141
141
  * @param inOrder Optional. Whether to iterate in order. True by default. You can dynamically set to
142
142
  * false in situations where iterating randomly would not matter and you need the
143
143
  * extra performance.
144
144
  */
145
145
  export function iterateTableInOrder<K, V>(
146
- luaTable: LuaTable<K, V>,
146
+ luaMap: LuaMap<K, V>,
147
147
  func: (key: K, value: V) => void,
148
148
  inOrder = true,
149
149
  ): void {
150
150
  // First, handle the trivial case of a non-deterministic iteration.
151
151
  if (!inOrder) {
152
- for (const [key, value] of pairs(luaTable)) {
152
+ for (const [key, value] of luaMap) {
153
153
  func(key, value);
154
154
  }
155
155
  return;
156
156
  }
157
157
 
158
- const keys = Object.keys(luaTable);
158
+ const keys = Object.keys(luaMap);
159
159
  const hasAllNumberKeys = keys.every((key) => isNumber(key));
160
160
  const hasAllStringKeys = keys.every((key) => isString(key));
161
161
  if (!hasAllNumberKeys && !hasAllStringKeys) {
162
162
  // Since the table has non-homogenous keys, we won't be able to sort it. Revert to
163
163
  // non-deterministic iteration in this case.
164
- for (const [key, value] of pairs(luaTable)) {
164
+ for (const [key, value] of luaMap) {
165
165
  func(key, value);
166
166
  }
167
167
  return;
168
168
  }
169
- keys.sort();
170
169
 
170
+ keys.sort();
171
171
  for (const key of keys) {
172
172
  const keyIndex = key as unknown as K;
173
- const value = luaTable.get(keyIndex);
174
- func(keyIndex, value);
173
+ const value = luaMap.get(keyIndex);
174
+ if (value !== undefined) {
175
+ func(keyIndex, value);
176
+ }
175
177
  }
176
178
  }
177
179
 
@@ -182,8 +184,8 @@ export function iterateTableInOrder<K, V>(
182
184
  * for.
183
185
  */
184
186
  export function tableHasKeys(
185
- luaTable: LuaTable<AnyNotNil, unknown>,
187
+ luaMap: LuaMap<AnyNotNil, unknown>,
186
188
  ...keys: string[]
187
189
  ): boolean {
188
- return keys.every((key) => luaTable.has(key));
190
+ return keys.every((key) => luaMap.has(key));
189
191
  }
@@ -146,7 +146,7 @@ export function newTSTLClass(oldClass: TSTLClass): TSTLClass {
146
146
 
147
147
  /** This is a re-implementation of the transpiled "__TS__New" function. */
148
148
  function newTSTLClassFromMetatable(metatable: TSTLClassMetatable): TSTLClass {
149
- const newClass = new LuaTable<AnyNotNil, unknown>();
149
+ const newClass = new LuaMap<AnyNotNil, unknown>();
150
150
  const newClassMetatable = setmetatable(
151
151
  newClass,
152
152
  metatable.constructor.prototype,
@@ -27,7 +27,9 @@ export function isString(variable: unknown): variable is string {
27
27
  return type(variable) === "string";
28
28
  }
29
29
 
30
- export function isTable(variable: unknown): variable is LuaTable {
30
+ export function isTable(
31
+ variable: unknown,
32
+ ): variable is LuaMap<AnyNotNil, unknown> {
31
33
  return type(variable) === "table";
32
34
  }
33
35
 
@@ -6,7 +6,7 @@ import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
6
6
  import { copyValuesToTable, getNumbersFromTable, tableHasKeys } from "./table";
7
7
  import { isTable } from "./types";
8
8
 
9
- type SerializedVector = LuaTable<string, unknown> & {
9
+ type SerializedVector = LuaMap<string, unknown> & {
10
10
  readonly __serializedVectorBrand: symbol;
11
11
  };
12
12
 
@@ -55,7 +55,7 @@ export function copyVector(
55
55
  );
56
56
  }
57
57
 
58
- const vectorTable = new LuaTable<string, unknown>();
58
+ const vectorTable = new LuaMap<string, unknown>();
59
59
  copyValuesToTable(vector, KEYS, vectorTable);
60
60
  vectorTable.set(SerializationBrand.VECTOR, "");
61
61
  return vectorTable as SerializedVector;
@@ -69,7 +69,7 @@ export function copyVector(
69
69
  }
70
70
 
71
71
  const [x, y] = getNumbersFromTable(
72
- vector as LuaTable<string, unknown>,
72
+ vector as LuaMap<string, unknown>,
73
73
  OBJECT_NAME,
74
74
  ...KEYS,
75
75
  );
@@ -15,7 +15,7 @@
15
15
  * - `Set`
16
16
  * - serializable Isaac API classes (such as `Color`)
17
17
  * - TSTL classes (i.e. classes that you made yourself)
18
- * - sub-objects or a `LuaTable` that contains the above values
18
+ * - sub-objects or a `LuaMap` that contains the above values
19
19
  *
20
20
  * (Unfortunately, it is not possible to create a recursive type definition that matches these
21
21
  * properties. This means that the TypeScript compiler will not be able to validate that you are
@@ -3,6 +3,6 @@ export interface TSTLClassMetatable {
3
3
  __index: unknown;
4
4
  constructor: {
5
5
  name: string;
6
- prototype: LuaMetatable<LuaTable<AnyNotNil, unknown>>;
6
+ prototype: LuaMetatable<LuaMap<AnyNotNil, unknown>>;
7
7
  };
8
8
  }
@@ -1,6 +1,7 @@
1
1
  /**
2
- * PlayerIndex is a specific type of string; see the documentation for the `getPlayerIndex`
3
- * function. Mods can signify that data structures handle `EntityPlayer` by using this type.
2
+ * PlayerIndex is a specific type of number that represents a unique identifier for a player. Mods
3
+ * can signify that data structures handle `EntityPlayer` by using this type. For more information,
4
+ * see the documentation for the `getPlayerIndex` function.
4
5
  *
5
6
  * For example:
6
7
  *
@@ -1,3 +1,3 @@
1
- export type IsaacAPIClass = LuaTable<string, unknown> & {
1
+ export type IsaacAPIClass = LuaMap<string, unknown> & {
2
2
  readonly __isaacAPIClassBrand: symbol;
3
3
  };
@@ -1,3 +1,3 @@
1
- export type SerializedIsaacAPIClass = LuaTable<string, unknown> & {
1
+ export type SerializedIsaacAPIClass = LuaMap<string, unknown> & {
2
2
  readonly __serializedIsaacAPIClassBrand: symbol;
3
3
  };
@@ -1,3 +1,3 @@
1
- export type TSTLClass = LuaTable<AnyNotNil, unknown> & {
1
+ export type TSTLClass = LuaMap<AnyNotNil, unknown> & {
2
2
  readonly __tstlClassBrand: symbol;
3
3
  };
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializationBrand.d.ts","sourceRoot":"","sources":["../../../src/features/saveDataManager/serializationBrand.ts"],"names":[],"mappings":"AASA,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAM1D"}