isaacscript-common 9.20.0 → 10.0.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 (33) hide show
  1. package/dist/index.d.ts +5 -3
  2. package/dist/isaacscript-common.lua +65 -44
  3. package/dist/lualib_bundle.lua +53 -37
  4. package/dist/package.lua +2 -2
  5. package/dist/src/features/saveDataManager/load.d.ts +1 -1
  6. package/dist/src/features/saveDataManager/maps.d.ts +1 -1
  7. package/dist/src/features/saveDataManager/merge.d.ts +1 -1
  8. package/dist/src/features/saveDataManager/save.d.ts +1 -1
  9. package/dist/src/functions/bitSet128.d.ts +1 -1
  10. package/dist/src/functions/color.d.ts +1 -1
  11. package/dist/src/functions/entities.d.ts +1 -1
  12. package/dist/src/functions/globals.d.ts +1 -1
  13. package/dist/src/functions/jsonHelpers.d.ts +1 -1
  14. package/dist/src/functions/kColor.d.ts +1 -1
  15. package/dist/src/functions/log.d.ts +2 -2
  16. package/dist/src/functions/log.d.ts.map +1 -1
  17. package/dist/src/functions/positionVelocity.d.ts +2 -0
  18. package/dist/src/functions/positionVelocity.d.ts.map +1 -1
  19. package/dist/src/functions/positionVelocity.lua +2 -0
  20. package/dist/src/functions/rng.d.ts +1 -1
  21. package/dist/src/functions/table.d.ts +2 -2
  22. package/dist/src/functions/table.d.ts.map +1 -1
  23. package/dist/src/functions/table.lua +5 -2
  24. package/dist/src/functions/tstlClass.d.ts +1 -1
  25. package/dist/src/functions/types.d.ts +1 -1
  26. package/dist/src/functions/vector.d.ts +1 -1
  27. package/dist/src/interfaces/private/TSTLClassMetatable.d.ts +1 -1
  28. package/dist/src/types/SerializedIsaacAPIClass.d.ts +1 -1
  29. package/dist/src/types/TSTLClass.d.ts +1 -1
  30. package/package.json +2 -2
  31. package/src/functions/log.ts +8 -6
  32. package/src/functions/positionVelocity.ts +2 -0
  33. package/src/functions/table.ts +10 -4
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
1
2
  /// <reference types="isaac-typescript-definitions" />
2
3
  /// <reference types="lua-types/5.3" />
3
- /// <reference types="typescript-to-lua/language-extensions" />
4
4
 
5
5
  import { ActiveSlot } from 'isaac-typescript-definitions';
6
6
  import { BackdropType } from 'isaac-typescript-definitions';
@@ -2157,6 +2157,8 @@ export declare function find<T>(array: T[], func: (value: T, index: number, arra
2157
2157
  * @param startingPosition The position to start searching from. If this position is not overlapping
2158
2158
  * with anything, then it will be returned.
2159
2159
  * @param avoidActiveEntities Optional. Default is false.
2160
+ * @param minimumDistance Optional. If specified, will ensure that the randomly generated position
2161
+ * is equal to or greater than the distance provided.
2160
2162
  */
2161
2163
  export declare function findFreePosition(startingPosition: Vector, avoidActiveEntities?: boolean, minimumDistance?: float): Vector;
2162
2164
 
@@ -6475,7 +6477,7 @@ export declare const itemConfig: ItemConfig;
6475
6477
  * false in situations where iterating randomly would not matter and you need the
6476
6478
  * extra performance.
6477
6479
  */
6478
- export declare function iterateTableInOrder<K, V>(luaMap: LuaMap<K, V>, func: (key: K, value: V) => void, inOrder?: boolean): void;
6480
+ export declare function iterateTableInOrder<K extends AnyNotNil, V>(luaMap: LuaMap<K, V>, func: (key: K, value: V) => void, inOrder?: boolean): void;
6479
6481
 
6480
6482
  /**
6481
6483
  * Helper function for non-TypeScript users to convert an array to a string with the specified
@@ -6824,7 +6826,7 @@ export declare function logTable(luaTable: unknown, parentTables?: number): void
6824
6826
  * Helper function to print out the differences between the entries of two tables. Note that this
6825
6827
  * will only do a shallow comparison.
6826
6828
  */
6827
- export declare function logTableDifferences<K, V>(table1: LuaMap<K, V>, table2: LuaMap<K, V>): void;
6829
+ export declare function logTableDifferences<K extends AnyNotNil, V>(table1: LuaMap<K, V>, table2: LuaMap<K, V>): void;
6828
6830
 
6829
6831
  /** Helper function for printing out every tear flag that is turned on. Useful when debugging. */
6830
6832
  export declare function logTearFlags(flags: TearFlag | BitFlags<TearFlag>): void;
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 9.20.0
3
+ isaacscript-common 10.0.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -304,11 +304,15 @@ local function __TS__ArrayPushArray(self, items)
304
304
  return len
305
305
  end
306
306
 
307
+ local function __TS__CountVarargs(...)
308
+ return select("#", ...)
309
+ end
310
+
307
311
  local function __TS__ArrayReduce(self, callbackFn, ...)
308
312
  local len = #self
309
313
  local k = 0
310
314
  local accumulator = nil
311
- if select("#", ...) ~= 0 then
315
+ if __TS__CountVarargs(...) ~= 0 then
312
316
  accumulator = ...
313
317
  elseif len > 0 then
314
318
  accumulator = self[1]
@@ -332,7 +336,7 @@ local function __TS__ArrayReduceRight(self, callbackFn, ...)
332
336
  local len = #self
333
337
  local k = len - 1
334
338
  local accumulator = nil
335
- if select("#", ...) ~= 0 then
339
+ if __TS__CountVarargs(...) ~= 0 then
336
340
  accumulator = ...
337
341
  elseif len > 0 then
338
342
  accumulator = self[k + 1]
@@ -448,7 +452,7 @@ end
448
452
  local function __TS__ArraySplice(self, ...)
449
453
  local args = {...}
450
454
  local len = #self
451
- local actualArgumentCount = select("#", ...)
455
+ local actualArgumentCount = __TS__CountVarargs(...)
452
456
  local start = args[1]
453
457
  local deleteCount = args[2]
454
458
  if start < 0 then
@@ -1065,6 +1069,16 @@ local function __TS__DecorateParam(paramIndex, decorator)
1065
1069
  return function(____, target, key) return decorator(nil, target, key, paramIndex) end
1066
1070
  end
1067
1071
 
1072
+ local function __TS__StringIncludes(self, searchString, position)
1073
+ if not position then
1074
+ position = 1
1075
+ else
1076
+ position = position + 1
1077
+ end
1078
+ local index = string.find(self, searchString, position, true)
1079
+ return index ~= nil
1080
+ end
1081
+
1068
1082
  local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
1069
1083
  do
1070
1084
  local function getErrorStack(self, constructor)
@@ -1079,13 +1093,18 @@ do
1079
1093
  break
1080
1094
  end
1081
1095
  end
1082
- return debug.traceback(nil, level)
1096
+ if __TS__StringIncludes(_VERSION, "Lua 5.0") then
1097
+ return debug.traceback(("[Level " .. tostring(level)) .. "]")
1098
+ else
1099
+ return debug.traceback(nil, level)
1100
+ end
1083
1101
  end
1084
1102
  local function wrapErrorToString(self, getDescription)
1085
1103
  return function(self)
1086
1104
  local description = getDescription(self)
1087
1105
  local caller = debug.getinfo(3, "f")
1088
- if _VERSION == "Lua 5.1" or caller and caller.func ~= error then
1106
+ local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0") or _VERSION == "Lua 5.1"
1107
+ if isClassicLua or caller and caller.func ~= error then
1089
1108
  return description
1090
1109
  else
1091
1110
  return (tostring(description) .. "\n") .. self.stack
@@ -1234,16 +1253,9 @@ do
1234
1253
  function __TS__Generator(fn)
1235
1254
  return function(...)
1236
1255
  local args = {...}
1237
- local argsLength = select("#", ...)
1256
+ local argsLength = __TS__CountVarargs(...)
1238
1257
  return {
1239
- ____coroutine = coroutine.create(function()
1240
- local ____fn_1 = fn
1241
- local ____unpack_0 = unpack
1242
- if ____unpack_0 == nil then
1243
- ____unpack_0 = table.unpack
1244
- end
1245
- return ____fn_1(____unpack_0(args, 1, argsLength))
1246
- end),
1258
+ ____coroutine = coroutine.create(function() return fn(__TS__Unpack(args, 1, argsLength)) end),
1247
1259
  [Symbol.iterator] = generatorIterator,
1248
1260
  next = generatorNext
1249
1261
  }
@@ -1407,8 +1419,12 @@ do
1407
1419
  Map[Symbol.species] = Map
1408
1420
  end
1409
1421
 
1422
+ local __TS__Match = string.match
1423
+
1410
1424
  local __TS__MathAtan2 = math.atan2 or math.atan
1411
1425
 
1426
+ local __TS__MathModf = math.modf
1427
+
1412
1428
  local function __TS__MathSign(val)
1413
1429
  if val > 0 then
1414
1430
  return 1
@@ -1418,6 +1434,10 @@ local function __TS__MathSign(val)
1418
1434
  return 0
1419
1435
  end
1420
1436
 
1437
+ local function __TS__Modulo50(a, b)
1438
+ return a - math.floor(a / b) * b
1439
+ end
1440
+
1421
1441
  local function __TS__Number(value)
1422
1442
  local valueType = type(value)
1423
1443
  if valueType == "number" then
@@ -1464,7 +1484,7 @@ do
1464
1484
  if radix < 2 or radix > 36 then
1465
1485
  error("toString() radix argument must be between 2 and 36", 0)
1466
1486
  end
1467
- local integer, fraction = math.modf(math.abs(self))
1487
+ local integer, fraction = __TS__MathModf(math.abs(self))
1468
1488
  local result = ""
1469
1489
  if radix == 8 then
1470
1490
  result = string.format("%o", integer)
@@ -1620,7 +1640,7 @@ local function __TS__ObjectValues(obj)
1620
1640
  end
1621
1641
 
1622
1642
  local function __TS__ParseFloat(numberString)
1623
- local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
1643
+ local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
1624
1644
  if infinityMatch then
1625
1645
  local ____temp_0
1626
1646
  if __TS__StringAccess(infinityMatch, 0) == "-" then
@@ -1630,7 +1650,7 @@ local function __TS__ParseFloat(numberString)
1630
1650
  end
1631
1651
  return ____temp_0
1632
1652
  end
1633
- local number = tonumber(string.match(numberString, "^%s*(-?%d+%.?%d*)"))
1653
+ local number = tonumber(__TS__Match(numberString, "^%s*(-?%d+%.?%d*)"))
1634
1654
  local ____number_1 = number
1635
1655
  if ____number_1 == nil then
1636
1656
  ____number_1 = 0 / 0
@@ -1678,16 +1698,16 @@ do
1678
1698
  function __TS__ParseInt(numberString, base)
1679
1699
  if base == nil then
1680
1700
  base = 10
1681
- local hexMatch = string.match(numberString, "^%s*-?0[xX]")
1701
+ local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
1682
1702
  if hexMatch then
1683
1703
  base = 16
1684
- local ____string_match_result__0_0
1685
- if string.match(hexMatch, "-") then
1686
- ____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1704
+ local ____TS__Match_result__0_0
1705
+ if __TS__Match(hexMatch, "-") then
1706
+ ____TS__Match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1687
1707
  else
1688
- ____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1708
+ ____TS__Match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1689
1709
  end
1690
- numberString = ____string_match_result__0_0
1710
+ numberString = ____TS__Match_result__0_0
1691
1711
  end
1692
1712
  end
1693
1713
  if base < 2 or base > 36 then
@@ -1702,7 +1722,7 @@ do
1702
1722
  local allowedDigits = ____temp_1
1703
1723
  local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1704
1724
  local number = tonumber(
1705
- string.match(numberString, pattern),
1725
+ __TS__Match(numberString, pattern),
1706
1726
  base
1707
1727
  )
1708
1728
  if number == nil then
@@ -2014,13 +2034,13 @@ end
2014
2034
 
2015
2035
  local function __TS__SparseArrayNew(...)
2016
2036
  local sparseArray = {...}
2017
- sparseArray.sparseLength = select("#", ...)
2037
+ sparseArray.sparseLength = __TS__CountVarargs(...)
2018
2038
  return sparseArray
2019
2039
  end
2020
2040
 
2021
2041
  local function __TS__SparseArrayPush(sparseArray, ...)
2022
2042
  local args = {...}
2023
- local argsLen = select("#", ...)
2043
+ local argsLen = __TS__CountVarargs(...)
2024
2044
  local listLen = sparseArray.sparseLength
2025
2045
  for i = 1, argsLen do
2026
2046
  sparseArray[listLen + i] = args[i]
@@ -2135,6 +2155,8 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
2135
2155
  local trace
2136
2156
  if thread == nil and message == nil and level == nil then
2137
2157
  trace = originalTraceback()
2158
+ elseif __TS__StringIncludes(_VERSION, "Lua 5.0") then
2159
+ trace = originalTraceback((("[Level " .. tostring(level)) .. "] ") .. message)
2138
2160
  else
2139
2161
  trace = originalTraceback(thread, message, level)
2140
2162
  end
@@ -2160,7 +2182,7 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
2160
2182
  local function stringReplacer(____, file, line)
2161
2183
  local fileSourceMap = _G.__TS__sourcemap[file]
2162
2184
  if fileSourceMap and fileSourceMap[line] then
2163
- local chunkName = string.match(file, "%[string \"([^\"]+)\"%]")
2185
+ local chunkName = __TS__Match(file, "%[string \"([^\"]+)\"%]")
2164
2186
  local sourceName = string.gsub(chunkName, ".lua$", ".ts")
2165
2187
  local data = fileSourceMap[line]
2166
2188
  if type(data) == "number" then
@@ -2227,16 +2249,6 @@ local function __TS__StringEndsWith(self, searchString, endPosition)
2227
2249
  return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
2228
2250
  end
2229
2251
 
2230
- local function __TS__StringIncludes(self, searchString, position)
2231
- if not position then
2232
- position = 1
2233
- else
2234
- position = position + 1
2235
- end
2236
- local index = string.find(self, searchString, position, true)
2237
- return index ~= nil
2238
- end
2239
-
2240
2252
  local function __TS__StringPadEnd(self, maxLength, fillString)
2241
2253
  if fillString == nil then
2242
2254
  fillString = " "
@@ -2492,6 +2504,7 @@ return {
2492
2504
  __TS__Class = __TS__Class,
2493
2505
  __TS__ClassExtends = __TS__ClassExtends,
2494
2506
  __TS__CloneDescriptor = __TS__CloneDescriptor,
2507
+ __TS__CountVarargs = __TS__CountVarargs,
2495
2508
  __TS__Decorate = __TS__Decorate,
2496
2509
  __TS__DecorateParam = __TS__DecorateParam,
2497
2510
  __TS__Delete = __TS__Delete,
@@ -2509,8 +2522,11 @@ return {
2509
2522
  __TS__Iterator = __TS__Iterator,
2510
2523
  __TS__LuaIteratorSpread = __TS__LuaIteratorSpread,
2511
2524
  Map = Map,
2525
+ __TS__Match = __TS__Match,
2512
2526
  __TS__MathAtan2 = __TS__MathAtan2,
2527
+ __TS__MathModf = __TS__MathModf,
2513
2528
  __TS__MathSign = __TS__MathSign,
2529
+ __TS__Modulo50 = __TS__Modulo50,
2514
2530
  __TS__New = __TS__New,
2515
2531
  __TS__Number = __TS__Number,
2516
2532
  __TS__NumberIsFinite = __TS__NumberIsFinite,
@@ -4837,7 +4853,7 @@ return ____exports
4837
4853
  ["lua_modules.isaac-typescript-definitions.dist.package"] = function(...)
4838
4854
  return {
4839
4855
  name = "isaac-typescript-definitions",
4840
- version = "6.0.0",
4856
+ version = "7.0.0",
4841
4857
  description = "TypeScript definitions for The Binding of Isaac: Repentance.",
4842
4858
  keywords = {"isaac", "rebirth", "afterbirth", "repentance"},
4843
4859
  homepage = "https://isaacscript.github.io/",
@@ -4848,7 +4864,7 @@ return {
4848
4864
  type = "commonjs",
4849
4865
  main = "dist/src/index",
4850
4866
  types = "dist/src/index.d.ts",
4851
- dependencies = {["lua-types"] = "^2.12.2"}
4867
+ dependencies = {["lua-types"] = "^2.13.0"}
4852
4868
  }
4853
4869
  end,
4854
4870
  ["lua_modules.isaac-typescript-definitions.dist.src.enums.ActiveSlot"] = function(...)
@@ -18391,6 +18407,7 @@ local ____types = require("src.functions.types")
18391
18407
  local isBoolean = ____types.isBoolean
18392
18408
  local isNumber = ____types.isNumber
18393
18409
  local isString = ____types.isString
18410
+ local isTable = ____types.isTable
18394
18411
  --- In a `Map`, you can use the `clear` method to delete every element. However, in a `LuaMap`, the
18395
18412
  -- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
18396
18413
  function ____exports.clearTable(self, luaMap)
@@ -18400,9 +18417,11 @@ function ____exports.clearTable(self, luaMap)
18400
18417
  end
18401
18418
  --- Helper function to copy specific values from a object to a table.
18402
18419
  function ____exports.copyValuesToTable(self, object, keys, luaMap)
18403
- local otherTable = object
18420
+ if not isTable(nil, object) then
18421
+ error("Failed to copy an object values to a table, since the object was of type: " .. type(object))
18422
+ end
18404
18423
  for ____, key in ipairs(keys) do
18405
- local value = otherTable[key]
18424
+ local value = object[key]
18406
18425
  luaMap[key] = value
18407
18426
  end
18408
18427
  end
@@ -26728,6 +26747,8 @@ end
26728
26747
  -- @param startingPosition The position to start searching from. If this position is not overlapping
26729
26748
  -- with anything, then it will be returned.
26730
26749
  -- @param avoidActiveEntities Optional. Default is false.
26750
+ -- @param minimumDistance Optional. If specified, will ensure that the randomly generated position
26751
+ -- is equal to or greater than the distance provided.
26731
26752
  function ____exports.findFreePosition(self, startingPosition, avoidActiveEntities, minimumDistance)
26732
26753
  if avoidActiveEntities == nil then
26733
26754
  avoidActiveEntities = false
@@ -46824,7 +46845,7 @@ return ____exports
46824
46845
  ["package"] = function(...)
46825
46846
  return {
46826
46847
  name = "isaacscript-common",
46827
- version = "9.20.0",
46848
+ version = "10.0.0",
46828
46849
  description = "Helper functions and features for IsaacScript mods.",
46829
46850
  keywords = {"isaac", "rebirth", "afterbirth", "repentance"},
46830
46851
  homepage = "https://isaacscript.github.io/",
@@ -46835,7 +46856,7 @@ return {
46835
46856
  type = "commonjs",
46836
46857
  main = "dist/src/index",
46837
46858
  types = "dist/src/index.d.ts",
46838
- dependencies = {["isaac-typescript-definitions"] = "^6.0.0"}
46859
+ dependencies = {["isaac-typescript-definitions"] = "^7.0.0"}
46839
46860
  }
46840
46861
  end,
46841
46862
  ["src.functions.map"] = function(...)
@@ -255,11 +255,15 @@ local function __TS__ArrayPushArray(self, items)
255
255
  return len
256
256
  end
257
257
 
258
+ local function __TS__CountVarargs(...)
259
+ return select("#", ...)
260
+ end
261
+
258
262
  local function __TS__ArrayReduce(self, callbackFn, ...)
259
263
  local len = #self
260
264
  local k = 0
261
265
  local accumulator = nil
262
- if select("#", ...) ~= 0 then
266
+ if __TS__CountVarargs(...) ~= 0 then
263
267
  accumulator = ...
264
268
  elseif len > 0 then
265
269
  accumulator = self[1]
@@ -283,7 +287,7 @@ local function __TS__ArrayReduceRight(self, callbackFn, ...)
283
287
  local len = #self
284
288
  local k = len - 1
285
289
  local accumulator = nil
286
- if select("#", ...) ~= 0 then
290
+ if __TS__CountVarargs(...) ~= 0 then
287
291
  accumulator = ...
288
292
  elseif len > 0 then
289
293
  accumulator = self[k + 1]
@@ -399,7 +403,7 @@ end
399
403
  local function __TS__ArraySplice(self, ...)
400
404
  local args = {...}
401
405
  local len = #self
402
- local actualArgumentCount = select("#", ...)
406
+ local actualArgumentCount = __TS__CountVarargs(...)
403
407
  local start = args[1]
404
408
  local deleteCount = args[2]
405
409
  if start < 0 then
@@ -1016,6 +1020,16 @@ local function __TS__DecorateParam(paramIndex, decorator)
1016
1020
  return function(____, target, key) return decorator(nil, target, key, paramIndex) end
1017
1021
  end
1018
1022
 
1023
+ local function __TS__StringIncludes(self, searchString, position)
1024
+ if not position then
1025
+ position = 1
1026
+ else
1027
+ position = position + 1
1028
+ end
1029
+ local index = string.find(self, searchString, position, true)
1030
+ return index ~= nil
1031
+ end
1032
+
1019
1033
  local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
1020
1034
  do
1021
1035
  local function getErrorStack(self, constructor)
@@ -1030,13 +1044,18 @@ do
1030
1044
  break
1031
1045
  end
1032
1046
  end
1033
- return debug.traceback(nil, level)
1047
+ if __TS__StringIncludes(_VERSION, "Lua 5.0") then
1048
+ return debug.traceback(("[Level " .. tostring(level)) .. "]")
1049
+ else
1050
+ return debug.traceback(nil, level)
1051
+ end
1034
1052
  end
1035
1053
  local function wrapErrorToString(self, getDescription)
1036
1054
  return function(self)
1037
1055
  local description = getDescription(self)
1038
1056
  local caller = debug.getinfo(3, "f")
1039
- if _VERSION == "Lua 5.1" or caller and caller.func ~= error then
1057
+ local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0") or _VERSION == "Lua 5.1"
1058
+ if isClassicLua or caller and caller.func ~= error then
1040
1059
  return description
1041
1060
  else
1042
1061
  return (tostring(description) .. "\n") .. self.stack
@@ -1185,16 +1204,9 @@ do
1185
1204
  function __TS__Generator(fn)
1186
1205
  return function(...)
1187
1206
  local args = {...}
1188
- local argsLength = select("#", ...)
1207
+ local argsLength = __TS__CountVarargs(...)
1189
1208
  return {
1190
- ____coroutine = coroutine.create(function()
1191
- local ____fn_1 = fn
1192
- local ____unpack_0 = unpack
1193
- if ____unpack_0 == nil then
1194
- ____unpack_0 = table.unpack
1195
- end
1196
- return ____fn_1(____unpack_0(args, 1, argsLength))
1197
- end),
1209
+ ____coroutine = coroutine.create(function() return fn(__TS__Unpack(args, 1, argsLength)) end),
1198
1210
  [Symbol.iterator] = generatorIterator,
1199
1211
  next = generatorNext
1200
1212
  }
@@ -1358,8 +1370,12 @@ do
1358
1370
  Map[Symbol.species] = Map
1359
1371
  end
1360
1372
 
1373
+ local __TS__Match = string.match
1374
+
1361
1375
  local __TS__MathAtan2 = math.atan2 or math.atan
1362
1376
 
1377
+ local __TS__MathModf = math.modf
1378
+
1363
1379
  local function __TS__MathSign(val)
1364
1380
  if val > 0 then
1365
1381
  return 1
@@ -1369,6 +1385,10 @@ local function __TS__MathSign(val)
1369
1385
  return 0
1370
1386
  end
1371
1387
 
1388
+ local function __TS__Modulo50(a, b)
1389
+ return a - math.floor(a / b) * b
1390
+ end
1391
+
1372
1392
  local function __TS__Number(value)
1373
1393
  local valueType = type(value)
1374
1394
  if valueType == "number" then
@@ -1415,7 +1435,7 @@ do
1415
1435
  if radix < 2 or radix > 36 then
1416
1436
  error("toString() radix argument must be between 2 and 36", 0)
1417
1437
  end
1418
- local integer, fraction = math.modf(math.abs(self))
1438
+ local integer, fraction = __TS__MathModf(math.abs(self))
1419
1439
  local result = ""
1420
1440
  if radix == 8 then
1421
1441
  result = string.format("%o", integer)
@@ -1571,7 +1591,7 @@ local function __TS__ObjectValues(obj)
1571
1591
  end
1572
1592
 
1573
1593
  local function __TS__ParseFloat(numberString)
1574
- local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
1594
+ local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
1575
1595
  if infinityMatch then
1576
1596
  local ____temp_0
1577
1597
  if __TS__StringAccess(infinityMatch, 0) == "-" then
@@ -1581,7 +1601,7 @@ local function __TS__ParseFloat(numberString)
1581
1601
  end
1582
1602
  return ____temp_0
1583
1603
  end
1584
- local number = tonumber(string.match(numberString, "^%s*(-?%d+%.?%d*)"))
1604
+ local number = tonumber(__TS__Match(numberString, "^%s*(-?%d+%.?%d*)"))
1585
1605
  local ____number_1 = number
1586
1606
  if ____number_1 == nil then
1587
1607
  ____number_1 = 0 / 0
@@ -1629,16 +1649,16 @@ do
1629
1649
  function __TS__ParseInt(numberString, base)
1630
1650
  if base == nil then
1631
1651
  base = 10
1632
- local hexMatch = string.match(numberString, "^%s*-?0[xX]")
1652
+ local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
1633
1653
  if hexMatch then
1634
1654
  base = 16
1635
- local ____string_match_result__0_0
1636
- if string.match(hexMatch, "-") then
1637
- ____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1655
+ local ____TS__Match_result__0_0
1656
+ if __TS__Match(hexMatch, "-") then
1657
+ ____TS__Match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1638
1658
  else
1639
- ____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1659
+ ____TS__Match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1640
1660
  end
1641
- numberString = ____string_match_result__0_0
1661
+ numberString = ____TS__Match_result__0_0
1642
1662
  end
1643
1663
  end
1644
1664
  if base < 2 or base > 36 then
@@ -1653,7 +1673,7 @@ do
1653
1673
  local allowedDigits = ____temp_1
1654
1674
  local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1655
1675
  local number = tonumber(
1656
- string.match(numberString, pattern),
1676
+ __TS__Match(numberString, pattern),
1657
1677
  base
1658
1678
  )
1659
1679
  if number == nil then
@@ -1965,13 +1985,13 @@ end
1965
1985
 
1966
1986
  local function __TS__SparseArrayNew(...)
1967
1987
  local sparseArray = {...}
1968
- sparseArray.sparseLength = select("#", ...)
1988
+ sparseArray.sparseLength = __TS__CountVarargs(...)
1969
1989
  return sparseArray
1970
1990
  end
1971
1991
 
1972
1992
  local function __TS__SparseArrayPush(sparseArray, ...)
1973
1993
  local args = {...}
1974
- local argsLen = select("#", ...)
1994
+ local argsLen = __TS__CountVarargs(...)
1975
1995
  local listLen = sparseArray.sparseLength
1976
1996
  for i = 1, argsLen do
1977
1997
  sparseArray[listLen + i] = args[i]
@@ -2086,6 +2106,8 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
2086
2106
  local trace
2087
2107
  if thread == nil and message == nil and level == nil then
2088
2108
  trace = originalTraceback()
2109
+ elseif __TS__StringIncludes(_VERSION, "Lua 5.0") then
2110
+ trace = originalTraceback((("[Level " .. tostring(level)) .. "] ") .. message)
2089
2111
  else
2090
2112
  trace = originalTraceback(thread, message, level)
2091
2113
  end
@@ -2111,7 +2133,7 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
2111
2133
  local function stringReplacer(____, file, line)
2112
2134
  local fileSourceMap = _G.__TS__sourcemap[file]
2113
2135
  if fileSourceMap and fileSourceMap[line] then
2114
- local chunkName = string.match(file, "%[string \"([^\"]+)\"%]")
2136
+ local chunkName = __TS__Match(file, "%[string \"([^\"]+)\"%]")
2115
2137
  local sourceName = string.gsub(chunkName, ".lua$", ".ts")
2116
2138
  local data = fileSourceMap[line]
2117
2139
  if type(data) == "number" then
@@ -2178,16 +2200,6 @@ local function __TS__StringEndsWith(self, searchString, endPosition)
2178
2200
  return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
2179
2201
  end
2180
2202
 
2181
- local function __TS__StringIncludes(self, searchString, position)
2182
- if not position then
2183
- position = 1
2184
- else
2185
- position = position + 1
2186
- end
2187
- local index = string.find(self, searchString, position, true)
2188
- return index ~= nil
2189
- end
2190
-
2191
2203
  local function __TS__StringPadEnd(self, maxLength, fillString)
2192
2204
  if fillString == nil then
2193
2205
  fillString = " "
@@ -2443,6 +2455,7 @@ return {
2443
2455
  __TS__Class = __TS__Class,
2444
2456
  __TS__ClassExtends = __TS__ClassExtends,
2445
2457
  __TS__CloneDescriptor = __TS__CloneDescriptor,
2458
+ __TS__CountVarargs = __TS__CountVarargs,
2446
2459
  __TS__Decorate = __TS__Decorate,
2447
2460
  __TS__DecorateParam = __TS__DecorateParam,
2448
2461
  __TS__Delete = __TS__Delete,
@@ -2460,8 +2473,11 @@ return {
2460
2473
  __TS__Iterator = __TS__Iterator,
2461
2474
  __TS__LuaIteratorSpread = __TS__LuaIteratorSpread,
2462
2475
  Map = Map,
2476
+ __TS__Match = __TS__Match,
2463
2477
  __TS__MathAtan2 = __TS__MathAtan2,
2478
+ __TS__MathModf = __TS__MathModf,
2464
2479
  __TS__MathSign = __TS__MathSign,
2480
+ __TS__Modulo50 = __TS__Modulo50,
2465
2481
  __TS__New = __TS__New,
2466
2482
  __TS__Number = __TS__Number,
2467
2483
  __TS__NumberIsFinite = __TS__NumberIsFinite,
package/dist/package.lua CHANGED
@@ -1,6 +1,6 @@
1
1
  return {
2
2
  name = "isaacscript-common",
3
- version = "9.20.0",
3
+ version = "10.0.0",
4
4
  description = "Helper functions and features for IsaacScript mods.",
5
5
  keywords = {"isaac", "rebirth", "afterbirth", "repentance"},
6
6
  homepage = "https://isaacscript.github.io/",
@@ -11,5 +11,5 @@ return {
11
11
  type = "commonjs",
12
12
  main = "dist/src/index",
13
13
  types = "dist/src/index.d.ts",
14
- dependencies = {["isaac-typescript-definitions"] = "^6.0.0"}
14
+ dependencies = {["isaac-typescript-definitions"] = "^7.0.0"}
15
15
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- /// <reference types="typescript-to-lua/language-extensions" />
2
+ /// <reference types="@typescript-to-lua/language-extensions" />
3
3
  import { SaveData } from "../../interfaces/SaveData";
4
4
  export declare function loadFromDisk(mod: Mod, oldSaveData: LuaMap<string, SaveData>): void;
5
5
  //# sourceMappingURL=load.d.ts.map
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  import { SaveData } from "../../interfaces/SaveData";
3
3
  /**
4
4
  * The save data map is indexed by subscriber name. We use Lua tables instead of TypeScriptToLua
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /**
3
3
  * `merge` takes the values from a new table and recursively merges them into an old object (while
4
4
  * performing appropriate deserialization).
@@ -1,5 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- /// <reference types="typescript-to-lua/language-extensions" />
2
+ /// <reference types="@typescript-to-lua/language-extensions" />
3
3
  import { SaveData } from "../../interfaces/SaveData";
4
4
  export declare function saveToDisk(mod: Mod, saveDataMap: LuaMap<string, SaveData>, saveDataConditionalFuncMap: LuaMap<string, () => boolean>): void;
5
5
  //# sourceMappingURL=save.d.ts.map
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
3
  export declare type SerializedBitSet128 = LuaMap<string, unknown> & {
4
4
  readonly __serializedBitSet128Brand: symbol;
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
3
  /// <reference types="isaac-typescript-definitions" />
4
4
  /// <reference types="isaac-typescript-definitions" />
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  import { EntityType } from "isaac-typescript-definitions";
3
3
  import { AnyEntity } from "../types/AnyEntity";
4
4
  /**
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /**
3
3
  * Helper function to get a set containing all of the global variable names that are contained
4
4
  * within the Isaac environment by default.
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /**
3
3
  * Converts a JSON string to a Lua table.
4
4
  *
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
3
  /// <reference types="isaac-typescript-definitions" />
4
4
  /// <reference types="isaac-typescript-definitions" />
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  import { CollectibleType, DamageFlag, EntityFlag, ProjectileFlag, TearFlag, UseFlag } from "isaac-typescript-definitions";
3
3
  /**
4
4
  * Helper function to prefix the name of the function and the line number before a debug message.
@@ -66,7 +66,7 @@ export declare function logTable(luaTable: unknown, parentTables?: number): void
66
66
  * Helper function to print out the differences between the entries of two tables. Note that this
67
67
  * will only do a shallow comparison.
68
68
  */
69
- export declare function logTableDifferences<K, V>(table1: LuaMap<K, V>, table2: LuaMap<K, V>): void;
69
+ export declare function logTableDifferences<K extends AnyNotNil, V>(table1: LuaMap<K, V>, table2: LuaMap<K, V>): void;
70
70
  /** Helper function for printing out every tear flag that is turned on. Useful when debugging. */
71
71
  export declare function logTearFlags(flags: TearFlag | BitFlags<TearFlag>): void;
72
72
  /** Helper function for printing out every use flag that is turned on. Useful when debugging. */
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/functions/log.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,UAAU,EAKV,cAAc,EAGd,QAAQ,EACR,OAAO,EACR,MAAM,8BAA8B,CAAC;AAkBtC;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EAKX,kBAAkB,SAAI,GACrB,MAAM,CAiBR;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGrC;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAG3D;AAED,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,eAAe,EAAE,GAAG,IAAI,CAS7E;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAI3C;AAED,mGAAm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sE;AACtE,wBAAgB,OAAO,IAAI,IAAI,CA4B9B;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAiBrC;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI,CAUzE;AAED,gFAAgF;AAChF,wBAAgB,SAAS,IAAI,IAAI,CAQhC;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,SAAI,GAAG,IAAI,CA2ClE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,EACxD,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,IAAI,CA8BN;AAED,iGAAiG;AACjG,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAEvE;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAEpE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAoBnD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,IAAI,CAG7D"}
@@ -20,6 +20,8 @@ export declare function anyPlayerCloserThan(position: Vector, distance: float):
20
20
  * @param startingPosition The position to start searching from. If this position is not overlapping
21
21
  * with anything, then it will be returned.
22
22
  * @param avoidActiveEntities Optional. Default is false.
23
+ * @param minimumDistance Optional. If specified, will ensure that the randomly generated position
24
+ * is equal to or greater than the distance provided.
23
25
  */
24
26
  export declare function findFreePosition(startingPosition: Vector, avoidActiveEntities?: boolean, minimumDistance?: float): Vector;
25
27
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"positionVelocity.d.ts","sourceRoot":"","sources":["../../../src/functions/positionVelocity.ts"],"names":[],"mappings":";;;;AAaA,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAAE,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,GACZ,OAAO,CAIT;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,KAAK,GACd,OAAO,CAKT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,UAAQ,EAC3B,eAAe,CAAC,EAAE,KAAK,GACtB,MAAM,CAwCR;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAY5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAY7E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,IAAI,CAYN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EACtC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,IAAI,CAYN"}
1
+ {"version":3,"file":"positionVelocity.d.ts","sourceRoot":"","sources":["../../../src/functions/positionVelocity.ts"],"names":[],"mappings":";;;;AAaA,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAAE,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,GACZ,OAAO,CAIT;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,KAAK,GACd,OAAO,CAKT;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,UAAQ,EAC3B,eAAe,CAAC,EAAE,KAAK,GACtB,MAAM,CAwCR;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAY5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAY7E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,IAAI,CAYN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EACtC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,IAAI,CAYN"}
@@ -45,6 +45,8 @@ end
45
45
  -- @param startingPosition The position to start searching from. If this position is not overlapping
46
46
  -- with anything, then it will be returned.
47
47
  -- @param avoidActiveEntities Optional. Default is false.
48
+ -- @param minimumDistance Optional. If specified, will ensure that the randomly generated position
49
+ -- is equal to or greater than the distance provided.
48
50
  function ____exports.findFreePosition(self, startingPosition, avoidActiveEntities, minimumDistance)
49
51
  if avoidActiveEntities == nil then
50
52
  avoidActiveEntities = false
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
3
  /// <reference types="isaac-typescript-definitions" />
4
4
  export declare type SerializedRNG = LuaMap<string, unknown> & {
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /**
3
3
  * In a `Map`, you can use the `clear` method to delete every element. However, in a `LuaMap`, the
4
4
  * `clear` method does not exist. Use this helper function as a drop-in replacement for this.
@@ -42,7 +42,7 @@ export declare function getStringsFromTable(luaMap: LuaMap<string, unknown>, obj
42
42
  * false in situations where iterating randomly would not matter and you need the
43
43
  * extra performance.
44
44
  */
45
- export declare function iterateTableInOrder<K, V>(luaMap: LuaMap<K, V>, func: (key: K, value: V) => void, inOrder?: boolean): void;
45
+ export declare function iterateTableInOrder<K extends AnyNotNil, V>(luaMap: LuaMap<K, V>, func: (key: K, value: V) => void, inOrder?: boolean): void;
46
46
  /**
47
47
  * Helper function to check if a Lua table has all of the provided keys.
48
48
  *
@@ -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,wEAAwE;AACxE,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,IAAI,CAON;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,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M,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,6 +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 isTable = ____types.isTable
11
12
  --- In a `Map`, you can use the `clear` method to delete every element. However, in a `LuaMap`, the
12
13
  -- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
13
14
  function ____exports.clearTable(self, luaMap)
@@ -17,9 +18,11 @@ function ____exports.clearTable(self, luaMap)
17
18
  end
18
19
  --- Helper function to copy specific values from a object to a table.
19
20
  function ____exports.copyValuesToTable(self, object, keys, luaMap)
20
- local otherTable = object
21
+ if not isTable(nil, object) then
22
+ error("Failed to copy an object values to a table, since the object was of type: " .. type(object))
23
+ end
21
24
  for ____, key in ipairs(keys) do
22
- local value = otherTable[key]
25
+ local value = object[key]
23
26
  luaMap[key] = value
24
27
  end
25
28
  end
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  import { DefaultMap } from "../classes/DefaultMap";
3
3
  import { TSTLClass } from "../types/TSTLClass";
4
4
  /**
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /// <reference types="lua-types/5.3" />
3
3
  import { CardType, CollectibleType, LevelStage, NpcState, PillColor, PillEffect, PlayerType, TrinketType } from "isaac-typescript-definitions";
4
4
  /**
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  import { Direction } from "isaac-typescript-definitions";
3
3
  export declare type SerializedVector = LuaMap<string, unknown> & {
4
4
  readonly __serializedVectorBrand: symbol;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="lua-types/5.3" />
2
2
  /// <reference types="lua-types/5.3" />
3
3
  /// <reference types="lua-types/5.3" />
4
- /// <reference types="typescript-to-lua/language-extensions" />
4
+ /// <reference types="@typescript-to-lua/language-extensions" />
5
5
  export interface TSTLClassMetatable {
6
6
  ____constructor: () => void;
7
7
  __index: unknown;
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /**
3
3
  * This is a type representing an Isaac API class like `Color` or `RNG` that has been written to the
4
4
  * "save#.dat" file. It is used by the save data manager when reading and writing to that file.
@@ -1,4 +1,4 @@
1
- /// <reference types="typescript-to-lua/language-extensions" />
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  /**
3
3
  * This is a type representing a user-created class from TypeScript code.
4
4
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "9.20.0",
3
+ "version": "10.0.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/src/index",
23
23
  "types": "dist/src/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^6.0.0"
25
+ "isaac-typescript-definitions": "^7.0.0"
26
26
  }
27
27
  }
@@ -402,7 +402,7 @@ export function logTable(luaTable: unknown, parentTables = 0): void {
402
402
  * Helper function to print out the differences between the entries of two tables. Note that this
403
403
  * will only do a shallow comparison.
404
404
  */
405
- export function logTableDifferences<K, V>(
405
+ export function logTableDifferences<K extends AnyNotNil, V>(
406
406
  table1: LuaMap<K, V>,
407
407
  table2: LuaMap<K, V>,
408
408
  ): void {
@@ -420,13 +420,17 @@ export function logTableDifferences<K, V>(
420
420
 
421
421
  for (const key of keys) {
422
422
  if (!table1KeysSet.has(key)) {
423
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
423
424
  log(` Table 1 is missing key: ${key}`);
424
425
  } else if (!table2KeysSet.has(key)) {
426
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
425
427
  log(` Table 2 is missing key: ${key}`);
426
428
  } else {
427
- const value1 = table1.get(key as unknown as K);
428
- const value2 = table2.get(key as unknown as K);
429
+ const value1 = table1.get(key);
430
+
431
+ const value2 = table2.get(key);
429
432
  if (value1 !== value2) {
433
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
430
434
  log(` ${key} --> "${value1}" versus "${value2}"`);
431
435
  }
432
436
  }
@@ -453,9 +457,7 @@ export function logUserdata(userdata: unknown): void {
453
457
  return;
454
458
  }
455
459
 
456
- const metatable = getmetatable(userdata) as
457
- | LuaMap<AnyNotNil, unknown>
458
- | undefined;
460
+ const metatable = getmetatable(userdata);
459
461
  if (metatable === undefined) {
460
462
  log("Userdata: [no metatable]");
461
463
  return;
@@ -47,6 +47,8 @@ export function anyPlayerCloserThan(
47
47
  * @param startingPosition The position to start searching from. If this position is not overlapping
48
48
  * with anything, then it will be returned.
49
49
  * @param avoidActiveEntities Optional. Default is false.
50
+ * @param minimumDistance Optional. If specified, will ensure that the randomly generated position
51
+ * is equal to or greater than the distance provided.
50
52
  */
51
53
  export function findFreePosition(
52
54
  startingPosition: Vector,
@@ -1,4 +1,4 @@
1
- import { isBoolean, isNumber, isString } from "./types";
1
+ import { isBoolean, isNumber, isString, isTable } 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
@@ -16,10 +16,16 @@ export function copyValuesToTable(
16
16
  keys: string[],
17
17
  luaMap: LuaMap<string, unknown>,
18
18
  ): void {
19
- const otherTable = object as LuaMap<string, string | number>;
19
+ if (!isTable(object)) {
20
+ error(
21
+ `Failed to copy an object values to a table, since the object was of type: ${type(
22
+ object,
23
+ )}`,
24
+ );
25
+ }
20
26
 
21
27
  for (const key of keys) {
22
- const value = otherTable.get(key);
28
+ const value = object.get(key);
23
29
  luaMap.set(key, value);
24
30
  }
25
31
  }
@@ -142,7 +148,7 @@ export function getStringsFromTable(
142
148
  * false in situations where iterating randomly would not matter and you need the
143
149
  * extra performance.
144
150
  */
145
- export function iterateTableInOrder<K, V>(
151
+ export function iterateTableInOrder<K extends AnyNotNil, V>(
146
152
  luaMap: LuaMap<K, V>,
147
153
  func: (key: K, value: V) => void,
148
154
  inOrder = true,