isaacscript-common 26.2.1 → 26.3.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.
- package/dist/index.rollup.d.ts +58 -8
- package/dist/isaacscript-common.lua +36 -19
- package/dist/src/functions/logMisc.d.ts +51 -8
- package/dist/src/functions/logMisc.d.ts.map +1 -1
- package/dist/src/functions/logMisc.lua +65 -19
- package/dist/src/functions/vector.d.ts +7 -0
- package/dist/src/functions/vector.d.ts.map +1 -1
- package/dist/src/functions/vector.lua +5 -0
- package/package.json +1 -1
- package/src/functions/logMisc.ts +96 -18
- package/src/functions/vector.ts +7 -0
package/dist/index.rollup.d.ts
CHANGED
|
@@ -8722,12 +8722,29 @@ export declare function logAllGridEntities(this: void, includeWalls?: boolean, g
|
|
|
8722
8722
|
*/
|
|
8723
8723
|
export declare function logAndPrint(msg: string): void;
|
|
8724
8724
|
|
|
8725
|
-
/**
|
|
8726
|
-
|
|
8725
|
+
/**
|
|
8726
|
+
* Helper function to log all of the values in an array.
|
|
8727
|
+
*
|
|
8728
|
+
* @param array The array to log.
|
|
8729
|
+
* @param name Optional. The name of the array, which will be logged before the elements.
|
|
8730
|
+
*/
|
|
8731
|
+
export declare function logArray<T>(this: void, array: T[] | readonly T[], name?: string): void;
|
|
8727
8732
|
|
|
8728
|
-
|
|
8733
|
+
/**
|
|
8734
|
+
* Helper function to log the names of a collectible type array.
|
|
8735
|
+
*
|
|
8736
|
+
* @param collectibleTypes The collectible types to log.
|
|
8737
|
+
* @param name Optional. The name of the array, which will be logged before the elements.
|
|
8738
|
+
*/
|
|
8739
|
+
export declare function logCollectibleTypes(this: void, collectibleTypes: CollectibleType[], name?: string): void;
|
|
8729
8740
|
|
|
8730
|
-
|
|
8741
|
+
/**
|
|
8742
|
+
* Helper function to log a `Color` object.
|
|
8743
|
+
*
|
|
8744
|
+
* @param color The `Color` object to log.
|
|
8745
|
+
* @param name Optional. The name of the object, which will be logged before the properties.
|
|
8746
|
+
*/
|
|
8747
|
+
export declare function logColor(this: void, color: Color, name?: string): void;
|
|
8731
8748
|
|
|
8732
8749
|
/** Helper function for printing out every damage flag that is turned on. Useful when debugging. */
|
|
8733
8750
|
export declare function logDamageFlags(this: void, flags: DamageFlag | BitFlags<DamageFlag>): void;
|
|
@@ -8765,14 +8782,26 @@ export declare function logGridEntities(this: void, gridEntities: GridEntity[]):
|
|
|
8765
8782
|
/** Helper function for log information about a specific grid entity. */
|
|
8766
8783
|
export declare function logGridEntity(this: void, gridEntity: GridEntity): void;
|
|
8767
8784
|
|
|
8768
|
-
|
|
8785
|
+
/**
|
|
8786
|
+
* Helper function to log a `KColor` object.
|
|
8787
|
+
*
|
|
8788
|
+
* @param kColor The `KColor` object to log.
|
|
8789
|
+
* @param name Optional. The name of the object, which will be logged before the properties.
|
|
8790
|
+
*/
|
|
8791
|
+
export declare function logKColor(this: void, kColor: KColor, name?: string): void;
|
|
8769
8792
|
|
|
8770
8793
|
/**
|
|
8771
8794
|
* Helper function for printing out every level state flag that is turned on. Useful when debugging.
|
|
8772
8795
|
*/
|
|
8773
8796
|
export declare function logLevelStateFlags(this: void): void;
|
|
8774
8797
|
|
|
8775
|
-
|
|
8798
|
+
/**
|
|
8799
|
+
* Helper function to log a TSTL `Map`.
|
|
8800
|
+
*
|
|
8801
|
+
* @param map The TSTL `Map` to log.
|
|
8802
|
+
* @param name Optional. The name of the map, which will be logged before the elements.
|
|
8803
|
+
*/
|
|
8804
|
+
export declare function logMap(this: void, map: Map<AnyNotNil, unknown>, name?: string): void;
|
|
8776
8805
|
|
|
8777
8806
|
export declare function logMusic(this: void): void;
|
|
8778
8807
|
|
|
@@ -8808,7 +8837,13 @@ export declare function logRoom(this: void): void;
|
|
|
8808
8837
|
*/
|
|
8809
8838
|
export declare function logSeedEffects(this: void): void;
|
|
8810
8839
|
|
|
8811
|
-
|
|
8840
|
+
/**
|
|
8841
|
+
* Helper function to log a TSTL `Set`.
|
|
8842
|
+
*
|
|
8843
|
+
* @param set The TSTL `Set` to log.
|
|
8844
|
+
* @param name Optional. The name of the set, which will be logged before the elements.
|
|
8845
|
+
*/
|
|
8846
|
+
export declare function logSet(this: void, set: Set<AnyNotNil> | ReadonlySet<AnyNotNil>, name?: string): void;
|
|
8812
8847
|
|
|
8813
8848
|
/** Helper function for logging every sound effect that is currently playing. */
|
|
8814
8849
|
export declare function logSounds(this: void): void;
|
|
@@ -8851,7 +8886,15 @@ export declare function logUseFlags(this: void, flags: UseFlag | BitFlags<UseFla
|
|
|
8851
8886
|
*/
|
|
8852
8887
|
export declare function logUserdata(this: void, userdata: unknown): void;
|
|
8853
8888
|
|
|
8854
|
-
|
|
8889
|
+
/**
|
|
8890
|
+
* Helper function to log a `Vector` object.
|
|
8891
|
+
*
|
|
8892
|
+
* @param vector The `Vector` object to log.
|
|
8893
|
+
* @param name Optional. The name of the object, which will be logged before the properties.
|
|
8894
|
+
* @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
8895
|
+
* false.
|
|
8896
|
+
*/
|
|
8897
|
+
export declare function logVector(this: void, vector: Vector, name?: string, round?: boolean): void;
|
|
8855
8898
|
|
|
8856
8899
|
/** Helper type to match all of the lowercase keys of an object. */
|
|
8857
8900
|
export declare type LowercaseKeys<T> = StartsWithLowercase<keyof T>;
|
|
@@ -15720,6 +15763,13 @@ export declare const VectorOne: Readonly<Vector>;
|
|
|
15720
15763
|
/** Helper function for finding out which way a vector is pointing. */
|
|
15721
15764
|
export declare function vectorToDirection(vector: Vector): Direction;
|
|
15722
15765
|
|
|
15766
|
+
/**
|
|
15767
|
+
* Helper function to convert a vector to a string.
|
|
15768
|
+
*
|
|
15769
|
+
* @param vector The vector to convert.
|
|
15770
|
+
* @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
15771
|
+
* false.
|
|
15772
|
+
*/
|
|
15723
15773
|
export declare function vectorToString(vector: Vector, round?: boolean): string;
|
|
15724
15774
|
|
|
15725
15775
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 26.
|
|
3
|
+
isaacscript-common 26.3.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -28489,6 +28489,7 @@ local ____isaacAPIClass = require("src.functions.isaacAPIClass")
|
|
|
28489
28489
|
local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
|
|
28490
28490
|
local ____log = require("src.functions.log")
|
|
28491
28491
|
local log = ____log.log
|
|
28492
|
+
local logAndPrint = ____log.logAndPrint
|
|
28492
28493
|
local ____playerHealth = require("src.functions.playerHealth")
|
|
28493
28494
|
local getPlayerHealth = ____playerHealth.getPlayerHealth
|
|
28494
28495
|
local ____players = require("src.functions.players")
|
|
@@ -28535,16 +28536,22 @@ function ____exports.logFlags(flags, flagEnum, description)
|
|
|
28535
28536
|
log(" n/a (no flags)")
|
|
28536
28537
|
end
|
|
28537
28538
|
end
|
|
28538
|
-
function ____exports.logArray(array)
|
|
28539
|
+
function ____exports.logArray(array, name)
|
|
28539
28540
|
if not isArray(nil, array, false) then
|
|
28540
28541
|
log("Tried to log an array, but the given object was not an array.")
|
|
28541
28542
|
return
|
|
28542
28543
|
end
|
|
28543
28544
|
local arrayString = arrayToString(nil, array)
|
|
28544
|
-
|
|
28545
|
+
if name == nil then
|
|
28546
|
+
name = "array"
|
|
28547
|
+
end
|
|
28548
|
+
log((("Logging " .. name) .. ": ") .. arrayString)
|
|
28545
28549
|
end
|
|
28546
|
-
function ____exports.logCollectibleTypes(collectibleTypes)
|
|
28547
|
-
|
|
28550
|
+
function ____exports.logCollectibleTypes(collectibleTypes, name)
|
|
28551
|
+
if name == nil then
|
|
28552
|
+
name = "collectibles"
|
|
28553
|
+
end
|
|
28554
|
+
log(("Logging " .. name) .. ":")
|
|
28548
28555
|
local i = 1
|
|
28549
28556
|
for ____, collectibleType in ipairs(collectibleTypes) do
|
|
28550
28557
|
local collectibleName = getCollectibleName(nil, collectibleType)
|
|
@@ -28552,8 +28559,11 @@ function ____exports.logCollectibleTypes(collectibleTypes)
|
|
|
28552
28559
|
i = i + 1
|
|
28553
28560
|
end
|
|
28554
28561
|
end
|
|
28555
|
-
function ____exports.logColor(color)
|
|
28556
|
-
|
|
28562
|
+
function ____exports.logColor(color, name)
|
|
28563
|
+
if name == nil then
|
|
28564
|
+
name = "color"
|
|
28565
|
+
end
|
|
28566
|
+
log((((((((((((((("Logging " .. name) .. ": R") .. tostring(color.R)) .. ", G") .. tostring(color.G)) .. ", B") .. tostring(color.B)) .. ", A") .. tostring(color.A)) .. ", RO") .. tostring(color.RO)) .. ", BO") .. tostring(color.BO)) .. ", GO") .. tostring(color.GO))
|
|
28557
28567
|
end
|
|
28558
28568
|
function ____exports.logDamageFlags(flags)
|
|
28559
28569
|
____exports.logFlags(flags, DamageFlag, "damage")
|
|
@@ -28563,12 +28573,11 @@ function ____exports.logEntityFlags(flags)
|
|
|
28563
28573
|
end
|
|
28564
28574
|
function ____exports.logEntityID(entity)
|
|
28565
28575
|
local entityID = getEntityID(nil, entity)
|
|
28566
|
-
log("
|
|
28576
|
+
log("Logging entity: " .. entityID)
|
|
28567
28577
|
end
|
|
28568
28578
|
function ____exports.logError(msg)
|
|
28569
28579
|
local errorMsg = "Error: " .. msg
|
|
28570
|
-
|
|
28571
|
-
print(errorMsg)
|
|
28580
|
+
logAndPrint(nil, errorMsg)
|
|
28572
28581
|
end
|
|
28573
28582
|
function ____exports.logGameStateFlags()
|
|
28574
28583
|
log("Logging game state flags:")
|
|
@@ -28587,8 +28596,11 @@ function ____exports.logGameStateFlags()
|
|
|
28587
28596
|
log(" n/a (no flags)")
|
|
28588
28597
|
end
|
|
28589
28598
|
end
|
|
28590
|
-
function ____exports.logKColor(kColor)
|
|
28591
|
-
|
|
28599
|
+
function ____exports.logKColor(kColor, name)
|
|
28600
|
+
if name == nil then
|
|
28601
|
+
name = "KColor"
|
|
28602
|
+
end
|
|
28603
|
+
log((((((((("Logging " .. name) .. ": R") .. tostring(kColor.Red)) .. ", G") .. tostring(kColor.Green)) .. ", B") .. tostring(kColor.Blue)) .. ", A") .. tostring(kColor.Alpha))
|
|
28592
28604
|
end
|
|
28593
28605
|
function ____exports.logLevelStateFlags()
|
|
28594
28606
|
local level = game:GetLevel()
|
|
@@ -28608,12 +28620,13 @@ function ____exports.logLevelStateFlags()
|
|
|
28608
28620
|
log(" n/a (no flags)")
|
|
28609
28621
|
end
|
|
28610
28622
|
end
|
|
28611
|
-
function ____exports.logMap(map)
|
|
28623
|
+
function ____exports.logMap(map, name)
|
|
28612
28624
|
if not isTSTLMap(nil, map) and not isDefaultMap(nil, map) then
|
|
28613
28625
|
log("Tried to log a TSTL map, but the given object was not a TSTL map.")
|
|
28614
28626
|
return
|
|
28615
28627
|
end
|
|
28616
|
-
|
|
28628
|
+
local suffix = name == nil and (" \"" .. tostring(name)) .. "\"" or ""
|
|
28629
|
+
log(("Printing out a TSTL map" .. suffix) .. ":")
|
|
28617
28630
|
local mapKeys = {__TS__Spread(map:keys())}
|
|
28618
28631
|
__TS__ArraySort(mapKeys)
|
|
28619
28632
|
for ____, key in ipairs(mapKeys) do
|
|
@@ -28681,7 +28694,7 @@ function ____exports.logRoom()
|
|
|
28681
28694
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
28682
28695
|
local roomListIndex = getRoomListIndex(nil)
|
|
28683
28696
|
local roomData = getRoomData(nil)
|
|
28684
|
-
log("
|
|
28697
|
+
log("Logging room information:")
|
|
28685
28698
|
if roomData == nil then
|
|
28686
28699
|
log("- Room data is undefined.")
|
|
28687
28700
|
else
|
|
@@ -28715,12 +28728,13 @@ function ____exports.logSeedEffects()
|
|
|
28715
28728
|
log(" n/a (no seed effects)")
|
|
28716
28729
|
end
|
|
28717
28730
|
end
|
|
28718
|
-
function ____exports.logSet(set)
|
|
28731
|
+
function ____exports.logSet(set, name)
|
|
28719
28732
|
if not isTSTLSet(nil, set) then
|
|
28720
28733
|
log("Tried to log a TSTL set, but the given object was not a TSTL set.")
|
|
28721
28734
|
return
|
|
28722
28735
|
end
|
|
28723
|
-
|
|
28736
|
+
local suffix = name == nil and (" \"" .. tostring(name)) .. "\"" or ""
|
|
28737
|
+
log(("Printing out a TSTL set" .. suffix) .. ":")
|
|
28724
28738
|
local setValues = getSortedSetValues(nil, set)
|
|
28725
28739
|
for ____, value in ipairs(setValues) do
|
|
28726
28740
|
log(" Value: " .. tostring(value))
|
|
@@ -28846,12 +28860,15 @@ function ____exports.logUserdata(userdata)
|
|
|
28846
28860
|
end
|
|
28847
28861
|
____exports.logTable(metatable)
|
|
28848
28862
|
end
|
|
28849
|
-
function ____exports.logVector(vector, round)
|
|
28863
|
+
function ____exports.logVector(vector, name, round)
|
|
28850
28864
|
if round == nil then
|
|
28851
28865
|
round = false
|
|
28852
28866
|
end
|
|
28867
|
+
if name == nil then
|
|
28868
|
+
name = "vector"
|
|
28869
|
+
end
|
|
28853
28870
|
local vectorString = vectorToString(nil, vector, round)
|
|
28854
|
-
log("
|
|
28871
|
+
log((("Logging " .. name) .. ": ") .. vectorString)
|
|
28855
28872
|
end
|
|
28856
28873
|
return ____exports
|
|
28857
28874
|
end,
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
2
2
|
import { CollectibleType, DamageFlag, EntityFlag, ProjectileFlag, TearFlag, UseFlag } from "isaac-typescript-definitions";
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to log all of the values in an array.
|
|
5
|
+
*
|
|
6
|
+
* @param array The array to log.
|
|
7
|
+
* @param name Optional. The name of the array, which will be logged before the elements.
|
|
8
|
+
*/
|
|
9
|
+
export declare function logArray<T>(this: void, array: T[] | readonly T[], name?: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Helper function to log the names of a collectible type array.
|
|
12
|
+
*
|
|
13
|
+
* @param collectibleTypes The collectible types to log.
|
|
14
|
+
* @param name Optional. The name of the array, which will be logged before the elements.
|
|
15
|
+
*/
|
|
16
|
+
export declare function logCollectibleTypes(this: void, collectibleTypes: CollectibleType[], name?: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Helper function to log a `Color` object.
|
|
19
|
+
*
|
|
20
|
+
* @param color The `Color` object to log.
|
|
21
|
+
* @param name Optional. The name of the object, which will be logged before the properties.
|
|
22
|
+
*/
|
|
23
|
+
export declare function logColor(this: void, color: Color, name?: string): void;
|
|
7
24
|
/** Helper function for printing out every damage flag that is turned on. Useful when debugging. */
|
|
8
25
|
export declare function logDamageFlags(this: void, flags: DamageFlag | BitFlags<DamageFlag>): void;
|
|
9
26
|
/** Helper function for printing out every entity flag that is turned on. Useful when debugging. */
|
|
@@ -22,12 +39,24 @@ export declare function logFlags<T extends BitFlag | BitFlag128>(this: void, fla
|
|
|
22
39
|
* Helper function for printing out every game state flag that is turned on. Useful when debugging.
|
|
23
40
|
*/
|
|
24
41
|
export declare function logGameStateFlags(this: void): void;
|
|
25
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Helper function to log a `KColor` object.
|
|
44
|
+
*
|
|
45
|
+
* @param kColor The `KColor` object to log.
|
|
46
|
+
* @param name Optional. The name of the object, which will be logged before the properties.
|
|
47
|
+
*/
|
|
48
|
+
export declare function logKColor(this: void, kColor: KColor, name?: string): void;
|
|
26
49
|
/**
|
|
27
50
|
* Helper function for printing out every level state flag that is turned on. Useful when debugging.
|
|
28
51
|
*/
|
|
29
52
|
export declare function logLevelStateFlags(this: void): void;
|
|
30
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Helper function to log a TSTL `Map`.
|
|
55
|
+
*
|
|
56
|
+
* @param map The TSTL `Map` to log.
|
|
57
|
+
* @param name Optional. The name of the map, which will be logged before the elements.
|
|
58
|
+
*/
|
|
59
|
+
export declare function logMap(this: void, map: Map<AnyNotNil, unknown>, name?: string): void;
|
|
31
60
|
export declare function logMusic(this: void): void;
|
|
32
61
|
export declare function logPlayerEffects(this: void, player: EntityPlayer): void;
|
|
33
62
|
export declare function logPlayerHealth(this: void, player: EntityPlayer): void;
|
|
@@ -42,7 +71,13 @@ export declare function logRoom(this: void): void;
|
|
|
42
71
|
* particular run.
|
|
43
72
|
*/
|
|
44
73
|
export declare function logSeedEffects(this: void): void;
|
|
45
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Helper function to log a TSTL `Set`.
|
|
76
|
+
*
|
|
77
|
+
* @param set The TSTL `Set` to log.
|
|
78
|
+
* @param name Optional. The name of the set, which will be logged before the elements.
|
|
79
|
+
*/
|
|
80
|
+
export declare function logSet(this: void, set: Set<AnyNotNil> | ReadonlySet<AnyNotNil>, name?: string): void;
|
|
46
81
|
/** Helper function for logging every sound effect that is currently playing. */
|
|
47
82
|
export declare function logSounds(this: void): void;
|
|
48
83
|
/**
|
|
@@ -77,5 +112,13 @@ export declare function logUseFlags(this: void, flags: UseFlag | BitFlags<UseFla
|
|
|
77
112
|
* the Isaac API).
|
|
78
113
|
*/
|
|
79
114
|
export declare function logUserdata(this: void, userdata: unknown): void;
|
|
80
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Helper function to log a `Vector` object.
|
|
117
|
+
*
|
|
118
|
+
* @param vector The `Vector` object to log.
|
|
119
|
+
* @param name Optional. The name of the object, which will be logged before the properties.
|
|
120
|
+
* @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
121
|
+
* false.
|
|
122
|
+
*/
|
|
123
|
+
export declare function logVector(this: void, vector: Vector, name?: string, round?: boolean): void;
|
|
81
124
|
//# sourceMappingURL=logMisc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logMisc.d.ts","sourceRoot":"","sources":["../../../src/functions/logMisc.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,UAAU,EAMV,cAAc,EAGd,QAAQ,EACR,OAAO,EACR,MAAM,8BAA8B,CAAC;AAoBtC
|
|
1
|
+
{"version":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Z,IAAI,CAgBN;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAQ1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,OAAO,EACjB,YAAY,SAAI,GACf,IAAI,CAuCN;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,EACxD,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,IAAI,CA8BN;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAkBhE;AAED,iGAAiG;AACjG,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,GACnC,IAAI,CAEN;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GACjC,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAoB/D;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,UAAQ,GACZ,IAAI,CAON"}
|
|
@@ -42,6 +42,7 @@ local ____isaacAPIClass = require("src.functions.isaacAPIClass")
|
|
|
42
42
|
local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
|
|
43
43
|
local ____log = require("src.functions.log")
|
|
44
44
|
local log = ____log.log
|
|
45
|
+
local logAndPrint = ____log.logAndPrint
|
|
45
46
|
local ____playerHealth = require("src.functions.playerHealth")
|
|
46
47
|
local getPlayerHealth = ____playerHealth.getPlayerHealth
|
|
47
48
|
local ____players = require("src.functions.players")
|
|
@@ -89,17 +90,30 @@ function ____exports.logFlags(flags, flagEnum, description)
|
|
|
89
90
|
log(" n/a (no flags)")
|
|
90
91
|
end
|
|
91
92
|
end
|
|
92
|
-
--- Helper function to
|
|
93
|
-
|
|
93
|
+
--- Helper function to log all of the values in an array.
|
|
94
|
+
--
|
|
95
|
+
-- @param array The array to log.
|
|
96
|
+
-- @param name Optional. The name of the array, which will be logged before the elements.
|
|
97
|
+
function ____exports.logArray(array, name)
|
|
94
98
|
if not isArray(nil, array, false) then
|
|
95
99
|
log("Tried to log an array, but the given object was not an array.")
|
|
96
100
|
return
|
|
97
101
|
end
|
|
98
102
|
local arrayString = arrayToString(nil, array)
|
|
99
|
-
|
|
103
|
+
if name == nil then
|
|
104
|
+
name = "array"
|
|
105
|
+
end
|
|
106
|
+
log((("Logging " .. name) .. ": ") .. arrayString)
|
|
100
107
|
end
|
|
101
|
-
function
|
|
102
|
-
|
|
108
|
+
--- Helper function to log the names of a collectible type array.
|
|
109
|
+
--
|
|
110
|
+
-- @param collectibleTypes The collectible types to log.
|
|
111
|
+
-- @param name Optional. The name of the array, which will be logged before the elements.
|
|
112
|
+
function ____exports.logCollectibleTypes(collectibleTypes, name)
|
|
113
|
+
if name == nil then
|
|
114
|
+
name = "collectibles"
|
|
115
|
+
end
|
|
116
|
+
log(("Logging " .. name) .. ":")
|
|
103
117
|
local i = 1
|
|
104
118
|
for ____, collectibleType in ipairs(collectibleTypes) do
|
|
105
119
|
local collectibleName = getCollectibleName(nil, collectibleType)
|
|
@@ -107,8 +121,15 @@ function ____exports.logCollectibleTypes(collectibleTypes)
|
|
|
107
121
|
i = i + 1
|
|
108
122
|
end
|
|
109
123
|
end
|
|
110
|
-
function
|
|
111
|
-
|
|
124
|
+
--- Helper function to log a `Color` object.
|
|
125
|
+
--
|
|
126
|
+
-- @param color The `Color` object to log.
|
|
127
|
+
-- @param name Optional. The name of the object, which will be logged before the properties.
|
|
128
|
+
function ____exports.logColor(color, name)
|
|
129
|
+
if name == nil then
|
|
130
|
+
name = "color"
|
|
131
|
+
end
|
|
132
|
+
log((((((((((((((("Logging " .. name) .. ": R") .. tostring(color.R)) .. ", G") .. tostring(color.G)) .. ", B") .. tostring(color.B)) .. ", A") .. tostring(color.A)) .. ", RO") .. tostring(color.RO)) .. ", BO") .. tostring(color.BO)) .. ", GO") .. tostring(color.GO))
|
|
112
133
|
end
|
|
113
134
|
--- Helper function for printing out every damage flag that is turned on. Useful when debugging.
|
|
114
135
|
function ____exports.logDamageFlags(flags)
|
|
@@ -120,7 +141,7 @@ function ____exports.logEntityFlags(flags)
|
|
|
120
141
|
end
|
|
121
142
|
function ____exports.logEntityID(entity)
|
|
122
143
|
local entityID = getEntityID(nil, entity)
|
|
123
|
-
log("
|
|
144
|
+
log("Logging entity: " .. entityID)
|
|
124
145
|
end
|
|
125
146
|
--- Helper function to log an error message and also print it to the console for better visibility.
|
|
126
147
|
--
|
|
@@ -128,8 +149,7 @@ end
|
|
|
128
149
|
-- prevents all of the subsequent code in the callback from running).
|
|
129
150
|
function ____exports.logError(msg)
|
|
130
151
|
local errorMsg = "Error: " .. msg
|
|
131
|
-
|
|
132
|
-
print(errorMsg)
|
|
152
|
+
logAndPrint(nil, errorMsg)
|
|
133
153
|
end
|
|
134
154
|
--- Helper function for printing out every game state flag that is turned on. Useful when debugging.
|
|
135
155
|
function ____exports.logGameStateFlags()
|
|
@@ -149,8 +169,15 @@ function ____exports.logGameStateFlags()
|
|
|
149
169
|
log(" n/a (no flags)")
|
|
150
170
|
end
|
|
151
171
|
end
|
|
152
|
-
function
|
|
153
|
-
|
|
172
|
+
--- Helper function to log a `KColor` object.
|
|
173
|
+
--
|
|
174
|
+
-- @param kColor The `KColor` object to log.
|
|
175
|
+
-- @param name Optional. The name of the object, which will be logged before the properties.
|
|
176
|
+
function ____exports.logKColor(kColor, name)
|
|
177
|
+
if name == nil then
|
|
178
|
+
name = "KColor"
|
|
179
|
+
end
|
|
180
|
+
log((((((((("Logging " .. name) .. ": R") .. tostring(kColor.Red)) .. ", G") .. tostring(kColor.Green)) .. ", B") .. tostring(kColor.Blue)) .. ", A") .. tostring(kColor.Alpha))
|
|
154
181
|
end
|
|
155
182
|
--- Helper function for printing out every level state flag that is turned on. Useful when debugging.
|
|
156
183
|
function ____exports.logLevelStateFlags()
|
|
@@ -171,12 +198,17 @@ function ____exports.logLevelStateFlags()
|
|
|
171
198
|
log(" n/a (no flags)")
|
|
172
199
|
end
|
|
173
200
|
end
|
|
174
|
-
function
|
|
201
|
+
--- Helper function to log a TSTL `Map`.
|
|
202
|
+
--
|
|
203
|
+
-- @param map The TSTL `Map` to log.
|
|
204
|
+
-- @param name Optional. The name of the map, which will be logged before the elements.
|
|
205
|
+
function ____exports.logMap(map, name)
|
|
175
206
|
if not isTSTLMap(nil, map) and not isDefaultMap(nil, map) then
|
|
176
207
|
log("Tried to log a TSTL map, but the given object was not a TSTL map.")
|
|
177
208
|
return
|
|
178
209
|
end
|
|
179
|
-
|
|
210
|
+
local suffix = name == nil and (" \"" .. tostring(name)) .. "\"" or ""
|
|
211
|
+
log(("Printing out a TSTL map" .. suffix) .. ":")
|
|
180
212
|
local mapKeys = {__TS__Spread(map:keys())}
|
|
181
213
|
__TS__ArraySort(mapKeys)
|
|
182
214
|
for ____, key in ipairs(mapKeys) do
|
|
@@ -246,7 +278,7 @@ function ____exports.logRoom()
|
|
|
246
278
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
247
279
|
local roomListIndex = getRoomListIndex(nil)
|
|
248
280
|
local roomData = getRoomData(nil)
|
|
249
|
-
log("
|
|
281
|
+
log("Logging room information:")
|
|
250
282
|
if roomData == nil then
|
|
251
283
|
log("- Room data is undefined.")
|
|
252
284
|
else
|
|
@@ -282,12 +314,17 @@ function ____exports.logSeedEffects()
|
|
|
282
314
|
log(" n/a (no seed effects)")
|
|
283
315
|
end
|
|
284
316
|
end
|
|
285
|
-
function
|
|
317
|
+
--- Helper function to log a TSTL `Set`.
|
|
318
|
+
--
|
|
319
|
+
-- @param set The TSTL `Set` to log.
|
|
320
|
+
-- @param name Optional. The name of the set, which will be logged before the elements.
|
|
321
|
+
function ____exports.logSet(set, name)
|
|
286
322
|
if not isTSTLSet(nil, set) then
|
|
287
323
|
log("Tried to log a TSTL set, but the given object was not a TSTL set.")
|
|
288
324
|
return
|
|
289
325
|
end
|
|
290
|
-
|
|
326
|
+
local suffix = name == nil and (" \"" .. tostring(name)) .. "\"" or ""
|
|
327
|
+
log(("Printing out a TSTL set" .. suffix) .. ":")
|
|
291
328
|
local setValues = getSortedSetValues(nil, set)
|
|
292
329
|
for ____, value in ipairs(setValues) do
|
|
293
330
|
log(" Value: " .. tostring(value))
|
|
@@ -432,11 +469,20 @@ function ____exports.logUserdata(userdata)
|
|
|
432
469
|
end
|
|
433
470
|
____exports.logTable(metatable)
|
|
434
471
|
end
|
|
435
|
-
function
|
|
472
|
+
--- Helper function to log a `Vector` object.
|
|
473
|
+
--
|
|
474
|
+
-- @param vector The `Vector` object to log.
|
|
475
|
+
-- @param name Optional. The name of the object, which will be logged before the properties.
|
|
476
|
+
-- @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
477
|
+
-- false.
|
|
478
|
+
function ____exports.logVector(vector, name, round)
|
|
436
479
|
if round == nil then
|
|
437
480
|
round = false
|
|
438
481
|
end
|
|
482
|
+
if name == nil then
|
|
483
|
+
name = "vector"
|
|
484
|
+
end
|
|
439
485
|
local vectorString = vectorToString(nil, vector, round)
|
|
440
|
-
log("
|
|
486
|
+
log((("Logging " .. name) .. ": ") .. vectorString)
|
|
441
487
|
end
|
|
442
488
|
return ____exports
|
|
@@ -55,5 +55,12 @@ export declare function serializeVector(vector: Vector): SerializedVector;
|
|
|
55
55
|
export declare function vectorEquals(vector1: Vector, vector2: Vector): boolean;
|
|
56
56
|
/** Helper function for finding out which way a vector is pointing. */
|
|
57
57
|
export declare function vectorToDirection(vector: Vector): Direction;
|
|
58
|
+
/**
|
|
59
|
+
* Helper function to convert a vector to a string.
|
|
60
|
+
*
|
|
61
|
+
* @param vector The vector to convert.
|
|
62
|
+
* @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
63
|
+
* false.
|
|
64
|
+
*/
|
|
58
65
|
export declare function vectorToString(vector: Vector, round?: boolean): string;
|
|
59
66
|
//# sourceMappingURL=vector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/functions/vector.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,yBAAyB,EACzB,SAAS,EACV,MAAM,8BAA8B,CAAC;AAatC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACvD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC,MAAM,CAAC;CACnD,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;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,SAAS,SAAO,GACf,OAAO,CAET;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,QAAQ,CAAC,MAAM,CAAC,CAOlB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,gBAAgB,CAM5B;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,M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G,MAAM,IAAI,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAWhE;AAED;;;;;GAKG;AACH,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;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,MAAM,CAIpE"}
|
|
@@ -119,6 +119,11 @@ function ____exports.vectorToDirection(self, vector)
|
|
|
119
119
|
local angleDegrees = vector:GetAngleDegrees()
|
|
120
120
|
return angleToDirection(nil, angleDegrees)
|
|
121
121
|
end
|
|
122
|
+
--- Helper function to convert a vector to a string.
|
|
123
|
+
--
|
|
124
|
+
-- @param vector The vector to convert.
|
|
125
|
+
-- @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
126
|
+
-- false.
|
|
122
127
|
function ____exports.vectorToString(self, vector, round)
|
|
123
128
|
if round == nil then
|
|
124
129
|
round = false
|
package/package.json
CHANGED
package/src/functions/logMisc.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { getEntityID } from "./entities";
|
|
|
21
21
|
import { getEnumEntries } from "./enums";
|
|
22
22
|
import { hasFlag } from "./flag";
|
|
23
23
|
import { getIsaacAPIClassName } from "./isaacAPIClass";
|
|
24
|
-
import { log } from "./log";
|
|
24
|
+
import { log, logAndPrint } from "./log";
|
|
25
25
|
import { getPlayerHealth } from "./playerHealth";
|
|
26
26
|
import { getEffectsList, getPlayerName } from "./players";
|
|
27
27
|
import { getRoomData, getRoomGridIndex, getRoomListIndex } from "./roomData";
|
|
@@ -32,8 +32,17 @@ import { isDefaultMap, isTSTLMap, isTSTLSet } from "./tstlClass";
|
|
|
32
32
|
import { isTable, isUserdata } from "./types";
|
|
33
33
|
import { vectorToString } from "./vector";
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Helper function to log all of the values in an array.
|
|
37
|
+
*
|
|
38
|
+
* @param array The array to log.
|
|
39
|
+
* @param name Optional. The name of the array, which will be logged before the elements.
|
|
40
|
+
*/
|
|
41
|
+
export function logArray<T>(
|
|
42
|
+
this: void,
|
|
43
|
+
array: T[] | readonly T[],
|
|
44
|
+
name?: string,
|
|
45
|
+
): void {
|
|
37
46
|
// We do not assume the given array has contiguous values in order to be more permissive about the
|
|
38
47
|
// kinds of arrays that will successfully log without a run-time error.
|
|
39
48
|
if (!isArray(array, false)) {
|
|
@@ -42,14 +51,28 @@ export function logArray<T>(this: void, array: T[] | readonly T[]): void {
|
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
const arrayString = arrayToString(array);
|
|
45
|
-
|
|
54
|
+
if (name === undefined) {
|
|
55
|
+
name = "array";
|
|
56
|
+
}
|
|
57
|
+
log(`Logging ${name}: ${arrayString}`);
|
|
46
58
|
}
|
|
47
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Helper function to log the names of a collectible type array.
|
|
62
|
+
*
|
|
63
|
+
* @param collectibleTypes The collectible types to log.
|
|
64
|
+
* @param name Optional. The name of the array, which will be logged before the elements.
|
|
65
|
+
*/
|
|
48
66
|
export function logCollectibleTypes(
|
|
49
67
|
this: void,
|
|
50
68
|
collectibleTypes: CollectibleType[],
|
|
69
|
+
name?: string,
|
|
51
70
|
): void {
|
|
52
|
-
|
|
71
|
+
if (name === undefined) {
|
|
72
|
+
name = "collectibles";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
log(`Logging ${name}:`);
|
|
53
76
|
|
|
54
77
|
let i = 1;
|
|
55
78
|
for (const collectibleType of collectibleTypes) {
|
|
@@ -59,9 +82,19 @@ export function logCollectibleTypes(
|
|
|
59
82
|
}
|
|
60
83
|
}
|
|
61
84
|
|
|
62
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Helper function to log a `Color` object.
|
|
87
|
+
*
|
|
88
|
+
* @param color The `Color` object to log.
|
|
89
|
+
* @param name Optional. The name of the object, which will be logged before the properties.
|
|
90
|
+
*/
|
|
91
|
+
export function logColor(this: void, color: Color, name?: string): void {
|
|
92
|
+
if (name === undefined) {
|
|
93
|
+
name = "color";
|
|
94
|
+
}
|
|
95
|
+
|
|
63
96
|
log(
|
|
64
|
-
`
|
|
97
|
+
`Logging ${name}: R${color.R}, G${color.G}, B${color.B}, A${color.A}, RO${color.RO}, BO${color.BO}, GO${color.GO}`,
|
|
65
98
|
);
|
|
66
99
|
}
|
|
67
100
|
|
|
@@ -83,7 +116,7 @@ export function logEntityFlags(
|
|
|
83
116
|
|
|
84
117
|
export function logEntityID(this: void, entity: Entity): void {
|
|
85
118
|
const entityID = getEntityID(entity);
|
|
86
|
-
log(`
|
|
119
|
+
log(`Logging entity: ${entityID}`);
|
|
87
120
|
}
|
|
88
121
|
|
|
89
122
|
/**
|
|
@@ -94,8 +127,7 @@ export function logEntityID(this: void, entity: Entity): void {
|
|
|
94
127
|
*/
|
|
95
128
|
export function logError(this: void, msg: string): void {
|
|
96
129
|
const errorMsg = `Error: ${msg}`;
|
|
97
|
-
|
|
98
|
-
print(errorMsg);
|
|
130
|
+
logAndPrint(errorMsg);
|
|
99
131
|
}
|
|
100
132
|
|
|
101
133
|
/** Helper function for printing out every flag that is turned on. Useful when debugging. */
|
|
@@ -147,9 +179,19 @@ export function logGameStateFlags(this: void): void {
|
|
|
147
179
|
}
|
|
148
180
|
}
|
|
149
181
|
|
|
150
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Helper function to log a `KColor` object.
|
|
184
|
+
*
|
|
185
|
+
* @param kColor The `KColor` object to log.
|
|
186
|
+
* @param name Optional. The name of the object, which will be logged before the properties.
|
|
187
|
+
*/
|
|
188
|
+
export function logKColor(this: void, kColor: KColor, name?: string): void {
|
|
189
|
+
if (name === undefined) {
|
|
190
|
+
name = "KColor";
|
|
191
|
+
}
|
|
192
|
+
|
|
151
193
|
log(
|
|
152
|
-
`
|
|
194
|
+
`Logging ${name}: R${kColor.Red}, G${kColor.Green}, B${kColor.Blue}, A${kColor.Alpha}`,
|
|
153
195
|
);
|
|
154
196
|
}
|
|
155
197
|
|
|
@@ -176,13 +218,24 @@ export function logLevelStateFlags(this: void): void {
|
|
|
176
218
|
}
|
|
177
219
|
}
|
|
178
220
|
|
|
179
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Helper function to log a TSTL `Map`.
|
|
223
|
+
*
|
|
224
|
+
* @param map The TSTL `Map` to log.
|
|
225
|
+
* @param name Optional. The name of the map, which will be logged before the elements.
|
|
226
|
+
*/
|
|
227
|
+
export function logMap(
|
|
228
|
+
this: void,
|
|
229
|
+
map: Map<AnyNotNil, unknown>,
|
|
230
|
+
name?: string,
|
|
231
|
+
): void {
|
|
180
232
|
if (!isTSTLMap(map) && !isDefaultMap(map)) {
|
|
181
233
|
log("Tried to log a TSTL map, but the given object was not a TSTL map.");
|
|
182
234
|
return;
|
|
183
235
|
}
|
|
184
236
|
|
|
185
|
-
|
|
237
|
+
const suffix = name === undefined ? ` "${name}"` : "";
|
|
238
|
+
log(`Printing out a TSTL map${suffix}:`);
|
|
186
239
|
|
|
187
240
|
const mapKeys = [...map.keys()];
|
|
188
241
|
mapKeys.sort();
|
|
@@ -271,7 +324,7 @@ export function logRoom(this: void): void {
|
|
|
271
324
|
const roomListIndex = getRoomListIndex();
|
|
272
325
|
const roomData = getRoomData();
|
|
273
326
|
|
|
274
|
-
log("
|
|
327
|
+
log("Logging room information:");
|
|
275
328
|
if (roomData === undefined) {
|
|
276
329
|
log("- Room data is undefined.");
|
|
277
330
|
} else {
|
|
@@ -316,16 +369,24 @@ export function logSeedEffects(this: void): void {
|
|
|
316
369
|
}
|
|
317
370
|
}
|
|
318
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Helper function to log a TSTL `Set`.
|
|
374
|
+
*
|
|
375
|
+
* @param set The TSTL `Set` to log.
|
|
376
|
+
* @param name Optional. The name of the set, which will be logged before the elements.
|
|
377
|
+
*/
|
|
319
378
|
export function logSet(
|
|
320
379
|
this: void,
|
|
321
380
|
set: Set<AnyNotNil> | ReadonlySet<AnyNotNil>,
|
|
381
|
+
name?: string,
|
|
322
382
|
): void {
|
|
323
383
|
if (!isTSTLSet(set)) {
|
|
324
384
|
log("Tried to log a TSTL set, but the given object was not a TSTL set.");
|
|
325
385
|
return;
|
|
326
386
|
}
|
|
327
387
|
|
|
328
|
-
|
|
388
|
+
const suffix = name === undefined ? ` "${name}"` : "";
|
|
389
|
+
log(`Printing out a TSTL set${suffix}:`);
|
|
329
390
|
|
|
330
391
|
const setValues = getSortedSetValues(set);
|
|
331
392
|
for (const value of setValues) {
|
|
@@ -510,7 +571,24 @@ export function logUserdata(this: void, userdata: unknown): void {
|
|
|
510
571
|
logTable(metatable);
|
|
511
572
|
}
|
|
512
573
|
|
|
513
|
-
|
|
574
|
+
/**
|
|
575
|
+
* Helper function to log a `Vector` object.
|
|
576
|
+
*
|
|
577
|
+
* @param vector The `Vector` object to log.
|
|
578
|
+
* @param name Optional. The name of the object, which will be logged before the properties.
|
|
579
|
+
* @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
580
|
+
* false.
|
|
581
|
+
*/
|
|
582
|
+
export function logVector(
|
|
583
|
+
this: void,
|
|
584
|
+
vector: Vector,
|
|
585
|
+
name?: string,
|
|
586
|
+
round = false,
|
|
587
|
+
): void {
|
|
588
|
+
if (name === undefined) {
|
|
589
|
+
name = "vector";
|
|
590
|
+
}
|
|
591
|
+
|
|
514
592
|
const vectorString = vectorToString(vector, round);
|
|
515
|
-
log(`
|
|
593
|
+
log(`Logging ${name}: ${vectorString}`);
|
|
516
594
|
}
|
package/src/functions/vector.ts
CHANGED
|
@@ -151,6 +151,13 @@ export function vectorToDirection(vector: Vector): Direction {
|
|
|
151
151
|
return angleToDirection(angleDegrees);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Helper function to convert a vector to a string.
|
|
156
|
+
*
|
|
157
|
+
* @param vector The vector to convert.
|
|
158
|
+
* @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
159
|
+
* false.
|
|
160
|
+
*/
|
|
154
161
|
export function vectorToString(vector: Vector, round = false): string {
|
|
155
162
|
const x = round ? Math.round(vector.X) : vector.X;
|
|
156
163
|
const y = round ? Math.round(vector.Y) : vector.Y;
|