isaacscript-common 1.2.80 → 1.2.83
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/features/saveDataManager/load.lua +2 -2
- package/dist/features/saveDataManager/save.lua +2 -2
- package/dist/functions/jsonHelpers.d.ts +16 -0
- package/dist/functions/jsonHelpers.lua +28 -0
- package/dist/functions/player.d.ts +3 -3
- package/dist/functions/revive.d.ts +8 -2
- package/dist/functions/revive.lua +13 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.lua +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@ local ____lualib = require("lualib_bundle")
|
|
|
3
3
|
local __TS__StringTrim = ____lualib.__TS__StringTrim
|
|
4
4
|
local ____exports = {}
|
|
5
5
|
local readSaveDatFile, tryLoadModData, DEFAULT_MOD_DATA
|
|
6
|
-
local
|
|
7
|
-
local jsonDecode =
|
|
6
|
+
local ____jsonHelpers = require("functions.jsonHelpers")
|
|
7
|
+
local jsonDecode = ____jsonHelpers.jsonDecode
|
|
8
8
|
local ____log = require("functions.log")
|
|
9
9
|
local log = ____log.log
|
|
10
10
|
local ____debug = require("features.saveDataManager.debug")
|
|
@@ -7,8 +7,8 @@ local getAllSaveDataToWriteToDisk
|
|
|
7
7
|
local ____deepCopy = require("functions.deepCopy")
|
|
8
8
|
local deepCopy = ____deepCopy.deepCopy
|
|
9
9
|
local SerializationType = ____deepCopy.SerializationType
|
|
10
|
-
local
|
|
11
|
-
local jsonEncode =
|
|
10
|
+
local ____jsonHelpers = require("functions.jsonHelpers")
|
|
11
|
+
local jsonEncode = ____jsonHelpers.jsonEncode
|
|
12
12
|
local ____log = require("functions.log")
|
|
13
13
|
local log = ____log.log
|
|
14
14
|
function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
|
+
/**
|
|
3
|
+
* Converts a Lua table to a JSON string.
|
|
4
|
+
* In most cases, this function will be used for writing data to a "save#.dat" file.
|
|
5
|
+
* If encoding fails, it will throw an error to prevent writing a blank string or corrupted data to
|
|
6
|
+
* a user's "save#.dat" file.
|
|
7
|
+
*/
|
|
8
|
+
export declare function jsonEncode(table: unknown): string;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a JSON string to a Lua table.
|
|
11
|
+
* In most cases, this function will be used for reading data from a "save#.dat" file.
|
|
12
|
+
* If decoding fails, it will return a blank Lua table instead of throwing an error.
|
|
13
|
+
* (This allows execution to continue in cases where users have no current save data or have
|
|
14
|
+
* manually removed their existing save data.)
|
|
15
|
+
*/
|
|
16
|
+
export declare function jsonDecode(jsonString: string): LuaTable;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local tryEncode, tryDecode
|
|
4
|
+
local json = require("@NoResolution:json")
|
|
5
|
+
local ____log = require("functions.log")
|
|
6
|
+
local log = ____log.log
|
|
7
|
+
function tryEncode(____table)
|
|
8
|
+
return json.encode(____table)
|
|
9
|
+
end
|
|
10
|
+
function tryDecode(jsonString)
|
|
11
|
+
return json.decode(jsonString)
|
|
12
|
+
end
|
|
13
|
+
function ____exports.jsonEncode(self, ____table)
|
|
14
|
+
local ok, jsonStringOrErrMsg = pcall(tryEncode, ____table)
|
|
15
|
+
if not ok then
|
|
16
|
+
error("Failed to convert the Lua table to JSON: " .. jsonStringOrErrMsg)
|
|
17
|
+
end
|
|
18
|
+
return jsonStringOrErrMsg
|
|
19
|
+
end
|
|
20
|
+
function ____exports.jsonDecode(self, jsonString)
|
|
21
|
+
local ok, luaTableOrErrMsg = pcall(tryDecode, jsonString)
|
|
22
|
+
if not ok then
|
|
23
|
+
log("Failed to convert the JSON string to a Lua table: " .. jsonString)
|
|
24
|
+
return {}
|
|
25
|
+
end
|
|
26
|
+
return luaTableOrErrMsg
|
|
27
|
+
end
|
|
28
|
+
return ____exports
|
|
@@ -97,9 +97,9 @@ export declare function getLastHeart(player: EntityPlayer): HealthType;
|
|
|
97
97
|
*/
|
|
98
98
|
export declare function getNewestPlayer(): EntityPlayer;
|
|
99
99
|
/**
|
|
100
|
-
* Returns the number of slots that the player has remaining for heart containers, accounting
|
|
101
|
-
* broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full
|
|
102
|
-
* hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
|
|
100
|
+
* Returns the number of slots that the player has remaining for new heart containers, accounting
|
|
101
|
+
* for broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full
|
|
102
|
+
* soul hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
|
|
103
103
|
*/
|
|
104
104
|
export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
|
|
105
105
|
/**
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int): boolean;
|
|
7
7
|
/**
|
|
8
|
-
* The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper,
|
|
9
|
-
*
|
|
8
|
+
* The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper, so
|
|
9
|
+
* use this helper function instead for more robust revival detection.
|
|
10
10
|
*/
|
|
11
11
|
export declare function willPlayerRevive(player: EntityPlayer): boolean;
|
|
12
12
|
/**
|
|
@@ -18,6 +18,12 @@ export declare function willPlayerRevive(player: EntityPlayer): boolean;
|
|
|
18
18
|
* Mysterious Paper be Missing Power is: `gameFrameCount % 4 === 3`
|
|
19
19
|
*/
|
|
20
20
|
export declare function willMysteriousPaperRevive(player: EntityPlayer): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Helper function to determine if the player will be revived by the Heartbreak collectible if they
|
|
23
|
+
* take fatal damage. This is contingent on the character that they are playing as and the amount of
|
|
24
|
+
* broken hearts that they already have.
|
|
25
|
+
*/
|
|
26
|
+
export declare function willReviveFromHeartbreak(player: EntityPlayer): boolean;
|
|
21
27
|
/**
|
|
22
28
|
* Helper function to determine if the Spirit Shackles item is in an enabled state. (It can be
|
|
23
29
|
* either enabled or disabled.)
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local ____player = require("functions.player")
|
|
4
4
|
local getDeathAnimationName = ____player.getDeathAnimationName
|
|
5
|
-
local
|
|
5
|
+
local getPlayerMaxHeartContainers = ____player.getPlayerMaxHeartContainers
|
|
6
6
|
local getPlayerNumHitsRemaining = ____player.getPlayerNumHitsRemaining
|
|
7
7
|
local hasLostCurse = ____player.hasLostCurse
|
|
8
|
+
local isKeeper = ____player.isKeeper
|
|
8
9
|
local ____sprite = require("functions.sprite")
|
|
9
10
|
local getFinalFrameOfAnimation = ____sprite.getFinalFrameOfAnimation
|
|
10
11
|
local ____trinketGive = require("functions.trinketGive")
|
|
@@ -19,6 +20,16 @@ function ____exports.willMysteriousPaperRevive(self, player)
|
|
|
19
20
|
local frameOfDeath = gameFrameCount + deathAnimationFrames + 1
|
|
20
21
|
return frameOfDeath % 4 == 3
|
|
21
22
|
end
|
|
23
|
+
function ____exports.willReviveFromHeartbreak(self, player)
|
|
24
|
+
if not player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) then
|
|
25
|
+
return false
|
|
26
|
+
end
|
|
27
|
+
local maxHeartContainers = getPlayerMaxHeartContainers(nil, player)
|
|
28
|
+
local numBrokenHeartsThatWillBeAdded = isKeeper(nil, player) and 1 or 2
|
|
29
|
+
local brokenHearts = player:GetBrokenHearts()
|
|
30
|
+
local numBrokenHeartsAfterRevival = numBrokenHeartsThatWillBeAdded + brokenHearts
|
|
31
|
+
return maxHeartContainers > numBrokenHeartsAfterRevival
|
|
32
|
+
end
|
|
22
33
|
function ____exports.willReviveFromSpiritShackles(self, player)
|
|
23
34
|
if not player:HasCollectible(CollectibleType.COLLECTIBLE_SPIRIT_SHACKLES) then
|
|
24
35
|
return false
|
|
@@ -53,8 +64,7 @@ function ____exports.isDamageToPlayerFatal(self, player, damageAmount, damageSou
|
|
|
53
64
|
if damageAmount < playerNumAllHearts then
|
|
54
65
|
return false
|
|
55
66
|
end
|
|
56
|
-
|
|
57
|
-
if player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) and playerAvailableHeartSlots >= 2 then
|
|
67
|
+
if ____exports.willReviveFromHeartbreak(nil, player) then
|
|
58
68
|
return false
|
|
59
69
|
end
|
|
60
70
|
if player:HasCollectible(CollectibleType.COLLECTIBLE_BROKEN_GLASS_CANNON) and gameFrameCount == lastDamageGameFrame then
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export * from "./functions/flying";
|
|
|
29
29
|
export * from "./functions/globals";
|
|
30
30
|
export * from "./functions/gridEntity";
|
|
31
31
|
export * from "./functions/input";
|
|
32
|
-
export * from "./functions/
|
|
32
|
+
export * from "./functions/jsonHelpers";
|
|
33
33
|
export * from "./functions/jsonRoom";
|
|
34
34
|
export * from "./functions/language";
|
|
35
35
|
export * from "./functions/log";
|
package/dist/index.lua
CHANGED
|
@@ -243,7 +243,7 @@ do
|
|
|
243
243
|
end
|
|
244
244
|
end
|
|
245
245
|
do
|
|
246
|
-
local ____export = require("functions.
|
|
246
|
+
local ____export = require("functions.jsonHelpers")
|
|
247
247
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
248
248
|
if ____exportKey ~= "default" then
|
|
249
249
|
____exports[____exportKey] = ____exportValue
|