isaacscript-common 1.2.136 → 1.2.139

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 (66) hide show
  1. package/dist/callbacks/postCustomDoorEnter.d.ts +8 -0
  2. package/dist/callbacks/postCustomDoorEnter.lua +35 -0
  3. package/dist/callbacks/postPlayerChangeHealth.lua +4 -64
  4. package/dist/callbacks/subscriptions/postCustomDoorEnter.d.ts +2 -0
  5. package/dist/callbacks/subscriptions/postCustomDoorEnter.lua +25 -0
  6. package/dist/constants.d.ts +7 -0
  7. package/dist/constants.lua +1 -0
  8. package/dist/features/deployJSONRoom.lua +11 -22
  9. package/dist/features/disableInputs.lua +6 -20
  10. package/dist/features/disableSound.lua +4 -12
  11. package/dist/features/extraConsoleCommands/commands.d.ts +334 -0
  12. package/dist/features/extraConsoleCommands/commands.lua +930 -0
  13. package/dist/features/extraConsoleCommands/init.d.ts +25 -0
  14. package/dist/features/extraConsoleCommands/init.lua +194 -0
  15. package/dist/features/extraConsoleCommands/v.d.ts +13 -0
  16. package/dist/features/extraConsoleCommands/v.lua +11 -0
  17. package/dist/features/forgottenSwitch.lua +3 -8
  18. package/dist/features/getCollectibleItemPoolType.lua +4 -9
  19. package/dist/features/isPonyActive.lua +3 -8
  20. package/dist/features/preventCollectibleRotate.lua +3 -8
  21. package/dist/features/runInNFrames.lua +6 -20
  22. package/dist/features/saveDataManager/constants.d.ts +3 -0
  23. package/dist/features/saveDataManager/constants.lua +5 -0
  24. package/dist/features/saveDataManager/exports.lua +9 -18
  25. package/dist/features/saveDataManager/load.lua +4 -3
  26. package/dist/features/saveDataManager/main.lua +4 -10
  27. package/dist/features/saveDataManager/merge.lua +2 -2
  28. package/dist/features/saveDataManager/save.lua +3 -1
  29. package/dist/features/sirenHelpers.lua +4 -8
  30. package/dist/featuresInitialized.d.ts +1 -1
  31. package/dist/featuresInitialized.lua +5 -0
  32. package/dist/functions/deepCopy.lua +2 -2
  33. package/dist/functions/log.d.ts +5 -1
  34. package/dist/functions/log.lua +175 -2
  35. package/dist/functions/map.d.ts +16 -0
  36. package/dist/functions/map.lua +24 -0
  37. package/dist/functions/player.d.ts +2 -2
  38. package/dist/functions/playerHealth.d.ts +3 -0
  39. package/dist/functions/playerHealth.lua +142 -0
  40. package/dist/functions/rooms.lua +4 -5
  41. package/dist/functions/run.d.ts +12 -0
  42. package/dist/functions/run.lua +25 -0
  43. package/dist/functions/utils.d.ts +0 -6
  44. package/dist/functions/utils.lua +0 -8
  45. package/dist/functions/vector.lua +8 -8
  46. package/dist/index.d.ts +8 -0
  47. package/dist/index.lua +62 -0
  48. package/dist/maps/cardMap.d.ts +3 -0
  49. package/dist/maps/cardMap.lua +202 -0
  50. package/dist/maps/characterMap.d.ts +3 -0
  51. package/dist/maps/characterMap.lua +90 -0
  52. package/dist/maps/pillEffectMap.d.ts +3 -0
  53. package/dist/maps/pillEffectMap.lua +88 -0
  54. package/dist/maps/roomTypeMap.d.ts +3 -0
  55. package/dist/maps/roomTypeMap.lua +43 -0
  56. package/dist/maps/roomTypeNameMap.d.ts +2 -0
  57. package/dist/maps/roomTypeNameMap.lua +38 -0
  58. package/dist/types/CallbackParametersCustom.d.ts +4 -0
  59. package/dist/types/HealthType.d.ts +4 -2
  60. package/dist/types/HealthType.lua +3 -1
  61. package/dist/types/ModCallbacksCustom.d.ts +2 -1
  62. package/dist/types/ModCallbacksCustom.lua +2 -0
  63. package/dist/types/ModUpgraded.lua +8 -0
  64. package/dist/types/PlayerIndex.d.ts +2 -2
  65. package/dist/upgradeMod.lua +3 -0
  66. package/package.json +1 -1
@@ -0,0 +1,25 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Enables extra console commands which are useful for debugging. See the `isaacscript-common`
4
+ * documentation for details on the commands that are added.
5
+ */
6
+ export declare function enableExtraConsoleCommands(mod: Mod): void;
7
+ /**
8
+ * Helper function to add a custom console command.
9
+ *
10
+ * The standard library comes with many existing console commands that are useful for debugging, but
11
+ * you can also add your own commands that are useful for your particular mod. It's easier to add
12
+ * commands to the existing command system than to add logic manually to the ExecuteCmd callback.
13
+ *
14
+ * Before using this function, you must first invoke `enableExtraConsoleCommands`.
15
+ */
16
+ export declare function addConsoleCommand(commandName: string, commandFunction: (params: string) => void): void;
17
+ /**
18
+ * Helper function to remove a custom console command.
19
+ *
20
+ * The standard library comes with many existing console commands that are useful for debugging. If
21
+ * you want to disable one of them, use this function.
22
+ *
23
+ * Before using this function, you must first invoke `enableExtraConsoleCommands`.
24
+ */
25
+ export declare function removeConsoleCommand(commandName: string): void;
@@ -0,0 +1,194 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local Map = ____lualib.Map
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ local featureEnabled, postUpdate, evaluateCacheFireDelay, evaluateCacheSpeed, entityTakeDmgPlayer, postCurseEval, executeCmd, postFireTear, commandFunctionsMap, initialized
7
+ local ____constants = require("constants")
8
+ local MAX_SPEED_STAT = ____constants.MAX_SPEED_STAT
9
+ local ____map = require("functions.map")
10
+ local getMapPartialMatch = ____map.getMapPartialMatch
11
+ local ____utils = require("functions.utils")
12
+ local printConsole = ____utils.printConsole
13
+ local ____exports = require("features.saveDataManager.exports")
14
+ local saveDataManager = ____exports.saveDataManager
15
+ local commands = require("features.extraConsoleCommands.commands")
16
+ local ____v = require("features.extraConsoleCommands.v")
17
+ local v = ____v.default
18
+ function featureEnabled(self)
19
+ return initialized
20
+ end
21
+ function postUpdate(self)
22
+ if v.run.spamBloodRights then
23
+ local player = Isaac.GetPlayer()
24
+ player:UseActiveItem(CollectibleType.COLLECTIBLE_BLOOD_RIGHTS)
25
+ end
26
+ end
27
+ function evaluateCacheFireDelay(self, player)
28
+ if v.run.maxTears then
29
+ player.FireDelay = 1
30
+ end
31
+ end
32
+ function evaluateCacheSpeed(self, player)
33
+ if v.run.maxSpeed then
34
+ player.MoveSpeed = MAX_SPEED_STAT
35
+ end
36
+ end
37
+ function entityTakeDmgPlayer(self)
38
+ if v.run.spamBloodRights then
39
+ return false
40
+ end
41
+ return nil
42
+ end
43
+ function postCurseEval(self, curses)
44
+ return v.persistent.disableCurses and LevelCurse.CURSE_NONE or curses
45
+ end
46
+ function executeCmd(self, command, params)
47
+ local commandFunction = getMapPartialMatch(nil, command, commandFunctionsMap)
48
+ if commandFunction == nil then
49
+ printConsole(nil, "That is an invalid console command.")
50
+ else
51
+ commandFunction(nil, params)
52
+ end
53
+ end
54
+ function postFireTear(self, tear)
55
+ if v.run.chaosCardTears then
56
+ tear:ChangeVariant(TearVariant.CHAOS_CARD)
57
+ end
58
+ if v.run.maxDamage then
59
+ tear.CollisionDamage = tear.CollisionDamage * 1000
60
+ tear:ChangeVariant(TearVariant.TOOTH)
61
+ end
62
+ end
63
+ commandFunctionsMap = __TS__New(Map)
64
+ initialized = false
65
+ function ____exports.enableExtraConsoleCommands(self, mod)
66
+ initialized = true
67
+ saveDataManager(nil, "extraConsoleCommands", v, featureEnabled)
68
+ mod:AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate)
69
+ mod:AddCallback(ModCallbacks.MC_EVALUATE_CACHE, evaluateCacheFireDelay, CacheFlag.CACHE_FIREDELAY)
70
+ mod:AddCallback(ModCallbacks.MC_EVALUATE_CACHE, evaluateCacheSpeed, CacheFlag.CACHE_SPEED)
71
+ mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, entityTakeDmgPlayer, EntityType.ENTITY_PLAYER)
72
+ mod:AddCallback(ModCallbacks.MC_POST_CURSE_EVAL, postCurseEval)
73
+ mod:AddCallback(ModCallbacks.MC_EXECUTE_CMD, executeCmd)
74
+ mod:AddCallback(ModCallbacks.MC_POST_FIRE_TEAR, postFireTear)
75
+ end
76
+ function ____exports.addConsoleCommand(self, commandName, commandFunction)
77
+ if not initialized then
78
+ error("Before adding extra console commands, you must first enable the feature by invoking the \"enableExtraConsoleCommands\" function.")
79
+ end
80
+ if commandFunctionsMap:has(commandName) then
81
+ error(("You cannot add a new console command of \"" .. commandName) .. "\" because there is already an existing command by that name. If you want to overwrite a command from the standard library, you can use the \"removeExtraConsoleCommand\" function.")
82
+ end
83
+ commandFunctionsMap:set(commandName, commandFunction)
84
+ end
85
+ function ____exports.removeConsoleCommand(self, commandName)
86
+ if not initialized then
87
+ error("Before removing console commands, you must first enable the feature by invoking the \"enableExtraConsoleCommands\" function.")
88
+ end
89
+ if not commandFunctionsMap:has(commandName) then
90
+ error(("The console command of \"" .. commandName) .. "\" does not exist, so you cannot remove it.")
91
+ end
92
+ commandFunctionsMap:delete(commandName)
93
+ end
94
+ commandFunctionsMap:set("addcharges", commands.addCharges)
95
+ commandFunctionsMap:set("angel", commands.angel)
96
+ commandFunctionsMap:set("ascent", commands.ascent)
97
+ commandFunctionsMap:set("bedroom", commands.bedroom)
98
+ commandFunctionsMap:set("bh", commands.bh)
99
+ commandFunctionsMap:set("blackhearts", commands.blackHearts)
100
+ commandFunctionsMap:set("blackmarket", commands.blackMarket)
101
+ commandFunctionsMap:set("bloodcharges", commands.bloodCharges)
102
+ commandFunctionsMap:set("bomb", commands.bomb)
103
+ commandFunctionsMap:set("bombs", commands.bombs)
104
+ commandFunctionsMap:set("bonehearts", commands.boneHearts)
105
+ commandFunctionsMap:set("boss", commands.boss)
106
+ commandFunctionsMap:set("bossrush", commands.bossRush)
107
+ commandFunctionsMap:set("bm", commands.bm)
108
+ commandFunctionsMap:set("brokenhearts", commands.brokenHearts)
109
+ commandFunctionsMap:set("card", commands.card)
110
+ commandFunctionsMap:set("cards", commands.cards)
111
+ commandFunctionsMap:set("cc", commands.cc)
112
+ commandFunctionsMap:set("chaoscardtears", commands.chaosCardTears)
113
+ commandFunctionsMap:set("character", commands.characterCommand)
114
+ commandFunctionsMap:set("charge", commands.charge)
115
+ commandFunctionsMap:set("cleanbedroom", commands.cleanBedroom)
116
+ commandFunctionsMap:set("coin", commands.coin)
117
+ commandFunctionsMap:set("coins", commands.coins)
118
+ commandFunctionsMap:set("crawlspace", commands.crawlspace)
119
+ commandFunctionsMap:set("d6", commands.d6)
120
+ commandFunctionsMap:set("d20", commands.d20)
121
+ commandFunctionsMap:set("damage", commands.damage)
122
+ commandFunctionsMap:set("dd", commands.dd)
123
+ commandFunctionsMap:set("devil", commands.devil)
124
+ commandFunctionsMap:set("dirtybedroom", commands.dirtyBedroom)
125
+ commandFunctionsMap:set("disablecurses", commands.disableCurses)
126
+ commandFunctionsMap:set("down", commands.down)
127
+ commandFunctionsMap:set("dungeon", commands.dungeon)
128
+ commandFunctionsMap:set("effects", commands.effects)
129
+ commandFunctionsMap:set("eh", commands.eh)
130
+ commandFunctionsMap:set("error", commands.error)
131
+ commandFunctionsMap:set("eternalhearts", commands.eternalHearts)
132
+ commandFunctionsMap:set("fool", commands.fool)
133
+ commandFunctionsMap:set("getposition", commands.getPosition)
134
+ commandFunctionsMap:set("gigabomb", commands.gigaBomb)
135
+ commandFunctionsMap:set("goldbomb", commands.goldBomb)
136
+ commandFunctionsMap:set("goldenbomb", commands.goldenBomb)
137
+ commandFunctionsMap:set("goldenhearts", commands.goldenHearts)
138
+ commandFunctionsMap:set("goldenkey", commands.goldenKey)
139
+ commandFunctionsMap:set("goldhearts", commands.goldHearts)
140
+ commandFunctionsMap:set("goldkey", commands.goldKey)
141
+ commandFunctionsMap:set("grid", commands.grid)
142
+ commandFunctionsMap:set("grid2", commands.grid2)
143
+ commandFunctionsMap:set("h", commands.h)
144
+ commandFunctionsMap:set("hearts", commands.hearts)
145
+ commandFunctionsMap:set("hitboxes", commands.hitboxes)
146
+ commandFunctionsMap:set("iamerror", commands.IAMERROR)
147
+ commandFunctionsMap:set("key", commands.key)
148
+ commandFunctionsMap:set("keys", commands.keys)
149
+ commandFunctionsMap:set("library", commands.library)
150
+ commandFunctionsMap:set("list", commands.list)
151
+ commandFunctionsMap:set("listall", commands.listAll)
152
+ commandFunctionsMap:set("listgrid", commands.listGrid)
153
+ commandFunctionsMap:set("listgridall", commands.listGridAll)
154
+ commandFunctionsMap:set("lowhp", commands.lowHP)
155
+ commandFunctionsMap:set("luck", commands.luck)
156
+ commandFunctionsMap:set("maxhearts", commands.maxHearts)
157
+ commandFunctionsMap:set("mh", commands.mh)
158
+ commandFunctionsMap:set("miniboss", commands.miniboss)
159
+ commandFunctionsMap:set("nocurses", commands.noCurses)
160
+ commandFunctionsMap:set("pill", commands.pill)
161
+ commandFunctionsMap:set("pills", commands.pills)
162
+ commandFunctionsMap:set("planetarium", commands.planetarium)
163
+ commandFunctionsMap:set("playsound", commands.playSound)
164
+ commandFunctionsMap:set("pocket", commands.pocket)
165
+ commandFunctionsMap:set("poopMana", commands.poopMana)
166
+ commandFunctionsMap:set("position", commands.positionCommand)
167
+ commandFunctionsMap:set("redhearts", commands.redHearts)
168
+ commandFunctionsMap:set("rh", commands.rh)
169
+ commandFunctionsMap:set("room", commands.roomCommand)
170
+ commandFunctionsMap:set("rottenhearts", commands.rottenHearts)
171
+ commandFunctionsMap:set("s", commands.s)
172
+ commandFunctionsMap:set("sacrifice", commands.sacrifice)
173
+ commandFunctionsMap:set("secret", commands.secret)
174
+ commandFunctionsMap:set("seeds", commands.seeds)
175
+ commandFunctionsMap:set("setcharges", commands.setCharges)
176
+ commandFunctionsMap:set("setposition", commands.setPosition)
177
+ commandFunctionsMap:set("sh", commands.sh)
178
+ commandFunctionsMap:set("shop", commands.shop)
179
+ commandFunctionsMap:set("smelt", commands.smelt)
180
+ commandFunctionsMap:set("soulcharges", commands.soulCharges)
181
+ commandFunctionsMap:set("soulhearts", commands.soulHearts)
182
+ commandFunctionsMap:set("sound", commands.sound)
183
+ commandFunctionsMap:set("sounds", commands.sounds)
184
+ commandFunctionsMap:set("spam", commands.spam)
185
+ commandFunctionsMap:set("spawngoldentrinket", commands.spawnGoldenTrinket)
186
+ commandFunctionsMap:set("speed", commands.speed)
187
+ commandFunctionsMap:set("supersecret", commands.superSecret)
188
+ commandFunctionsMap:set("startingroom", commands.startingRoom)
189
+ commandFunctionsMap:set("tears", commands.tears)
190
+ commandFunctionsMap:set("trapdoor", commands.trapdoorCommand)
191
+ commandFunctionsMap:set("treasure", commands.treasure)
192
+ commandFunctionsMap:set("ultrasecret", commands.ultraSecret)
193
+ commandFunctionsMap:set("warp", commands.warp)
194
+ return ____exports
@@ -0,0 +1,13 @@
1
+ declare const v: {
2
+ persistent: {
3
+ disableCurses: boolean;
4
+ };
5
+ run: {
6
+ chaosCardTears: boolean;
7
+ spamBloodRights: boolean;
8
+ maxDamage: boolean;
9
+ maxSpeed: boolean;
10
+ maxTears: boolean;
11
+ };
12
+ };
13
+ export default v;
@@ -0,0 +1,11 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local v = {persistent = {disableCurses = false}, run = {
4
+ chaosCardTears = false,
5
+ spamBloodRights = false,
6
+ maxDamage = false,
7
+ maxSpeed = false,
8
+ maxTears = false
9
+ }}
10
+ ____exports.default = v
11
+ return ____exports
@@ -1,8 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  local isActionTriggered, v
4
- local ____errors = require("errors")
5
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
4
+ local ____featuresInitialized = require("featuresInitialized")
5
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
6
6
  local ____exports = require("features.saveDataManager.exports")
7
7
  local saveDataManager = ____exports.saveDataManager
8
8
  function isActionTriggered(self, _entity, _inputHook, buttonAction)
@@ -13,18 +13,13 @@ function isActionTriggered(self, _entity, _inputHook, buttonAction)
13
13
  return nil
14
14
  end
15
15
  local FEATURE_NAME = "forgotten switcher"
16
- local initialized = false
17
16
  v = {run = {shouldSwitch = false}}
18
17
  function ____exports.forgottenSwitchInit(self, mod)
19
- initialized = true
20
18
  saveDataManager(nil, "forgottenSwitch", v)
21
19
  mod:AddCallback(ModCallbacks.MC_INPUT_ACTION, isActionTriggered, InputHook.IS_ACTION_TRIGGERED)
22
20
  end
23
21
  function ____exports.forgottenSwitch(self)
24
- if not initialized then
25
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
26
- error(msg)
27
- end
22
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
28
23
  v.run.shouldSwitch = true
29
24
  end
30
25
  return ____exports
@@ -6,8 +6,8 @@ local ____exports = {}
6
6
  local postPickupInitCollectible, v
7
7
  local ____cachedClasses = require("cachedClasses")
8
8
  local game = ____cachedClasses.game
9
- local ____errors = require("errors")
10
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
9
+ local ____featuresInitialized = require("featuresInitialized")
10
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
11
11
  local ____entity = require("functions.entity")
12
12
  local getEntityID = ____entity.getEntityID
13
13
  local ____rooms = require("functions.rooms")
@@ -21,21 +21,16 @@ function postPickupInitCollectible(self, pickup)
21
21
  v.run.collectibleItemPoolTypeMap:set(ptrHash, lastItemPoolType)
22
22
  end
23
23
  local FEATURE_NAME = "get collectible item pool type"
24
- local initialized = false
25
24
  v = {run = {collectibleItemPoolTypeMap = __TS__New(Map)}}
26
25
  function ____exports.getCollectibleItemPoolTypeInit(self, mod)
27
- initialized = true
28
26
  saveDataManager(nil, "getCollectibleItemPoolType", v)
29
27
  mod:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, postPickupInitCollectible, PickupVariant.PICKUP_COLLECTIBLE)
30
28
  end
31
29
  function ____exports.getCollectibleItemPoolType(self, collectible)
32
- if not initialized then
33
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
34
- error(msg)
35
- end
30
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
36
31
  if collectible.Type ~= EntityType.ENTITY_PICKUP or collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
37
32
  local entityID = getEntityID(nil, collectible)
38
- error("The \"getCollectibleItemPoolType()\" function was given a non-collectible: " .. entityID)
33
+ error("The \"getCollectibleItemPoolType\" function was given a non-collectible: " .. entityID)
39
34
  end
40
35
  local ptrHash = GetPtrHash(collectible)
41
36
  local itemPoolType = v.run.collectibleItemPoolTypeMap:get(ptrHash)
@@ -4,8 +4,8 @@ local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
6
  local postPEffectUpdate, FLAGS_WHEN_PONY_IS_ACTIVE, v
7
- local ____errors = require("errors")
8
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
7
+ local ____featuresInitialized = require("featuresInitialized")
8
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
9
9
  local ____flag = require("functions.flag")
10
10
  local hasFlag = ____flag.hasFlag
11
11
  local ____playerDataStructures = require("functions.playerDataStructures")
@@ -33,18 +33,13 @@ function postPEffectUpdate(self, player)
33
33
  end
34
34
  local FEATURE_NAME = "pony activation detector"
35
35
  FLAGS_WHEN_PONY_IS_ACTIVE = {EntityFlag.FLAG_NO_KNOCKBACK, EntityFlag.FLAG_NO_PHYSICS_KNOCKBACK, EntityFlag.FLAG_NO_DAMAGE_BLINK}
36
- local initialized = false
37
36
  v = {run = {playersIsPonyActive = __TS__New(Set)}}
38
37
  function ____exports.isPonyActiveInit(self, mod)
39
- initialized = true
40
38
  saveDataManager(nil, "isPonyActive", v)
41
39
  mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, postPEffectUpdate)
42
40
  end
43
41
  function ____exports.isPonyActive(self, player)
44
- if not initialized then
45
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
46
- error(msg)
47
- end
42
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
48
43
  return setHasPlayer(nil, v.run.playersIsPonyActive, player)
49
44
  end
50
45
  return ____exports
@@ -4,8 +4,8 @@ local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
6
  local useCardSoulOfIsaac, postPickupUpdateCollectible, v
7
- local ____errors = require("errors")
8
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
7
+ local ____featuresInitialized = require("featuresInitialized")
8
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
9
9
  local ____collectibles = require("functions.collectibles")
10
10
  local setCollectibleSubType = ____collectibles.setCollectibleSubType
11
11
  local ____exports = require("features.saveDataManager.exports")
@@ -23,19 +23,14 @@ function postPickupUpdateCollectible(self, pickup)
23
23
  end
24
24
  end
25
25
  local FEATURE_NAME = "prevent collectible rotation"
26
- local initialized = false
27
26
  v = {room = {trackedItems = __TS__New(Map)}}
28
27
  function ____exports.preventCollectibleRotateInit(self, mod)
29
- initialized = true
30
28
  saveDataManager(nil, "preventCollectibleRotate", v)
31
29
  mod:AddCallback(ModCallbacks.MC_USE_CARD, useCardSoulOfIsaac, Card.CARD_SOUL_ISAAC)
32
30
  mod:AddCallback(ModCallbacks.MC_POST_PICKUP_UPDATE, postPickupUpdateCollectible, PickupVariant.PICKUP_COLLECTIBLE)
33
31
  end
34
32
  function ____exports.preventCollectibleRotate(self, collectible, collectibleType)
35
- if not initialized then
36
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
37
- error(msg)
38
- end
33
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
39
34
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
40
35
  error("You cannot prevent the rotation for pickups of variant: " .. tostring(collectible.Variant))
41
36
  end
@@ -7,8 +7,8 @@ local ____exports = {}
7
7
  local postUpdate, postRender, checkExecuteQueuedFunctions, v
8
8
  local ____cachedClasses = require("cachedClasses")
9
9
  local game = ____cachedClasses.game
10
- local ____errors = require("errors")
11
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
10
+ local ____featuresInitialized = require("featuresInitialized")
11
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
12
12
  local ____exports = require("features.saveDataManager.exports")
13
13
  local saveDataManager = ____exports.saveDataManager
14
14
  function postUpdate(self)
@@ -40,46 +40,32 @@ function checkExecuteQueuedFunctions(self, frameCount, functionTuples)
40
40
  end
41
41
  end
42
42
  local FEATURE_NAME = "run in N frames"
43
- local initialized = false
44
43
  v = {dontSave = true, run = {queuedGameFunctionTuples = {}, queuedRenderFunctionTuples = {}}}
45
44
  function ____exports.runInNFramesInit(self, mod)
46
- initialized = true
47
45
  saveDataManager(nil, "runInNFrames", v)
48
46
  mod:AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate)
49
47
  mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
50
48
  end
51
49
  function ____exports.runInNGameFrames(self, func, frames)
52
- if not initialized then
53
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
54
- error(msg)
55
- end
50
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
56
51
  local gameFrameCount = game:GetFrameCount()
57
52
  local functionFireFrame = gameFrameCount + frames
58
53
  local tuple = {functionFireFrame, func}
59
54
  __TS__ArrayPush(v.run.queuedGameFunctionTuples, tuple)
60
55
  end
61
56
  function ____exports.runInNRenderFrames(self, func, frames)
62
- if not initialized then
63
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
64
- error(msg)
65
- end
57
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
66
58
  local isaacFrameCount = Isaac.GetFrameCount()
67
59
  local functionFireFrame = isaacFrameCount + frames
68
60
  local tuple = {functionFireFrame, func}
69
61
  __TS__ArrayPush(v.run.queuedRenderFunctionTuples, tuple)
70
62
  end
71
63
  function ____exports.runNextGameFrame(self, func)
72
- if not initialized then
73
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
74
- error(msg)
75
- end
64
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
76
65
  ____exports.runInNGameFrames(nil, func, 1)
77
66
  end
78
67
  function ____exports.runNextRenderFrame(self, func)
79
- if not initialized then
80
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
81
- error(msg)
82
- end
68
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
83
69
  ____exports.runInNRenderFrames(nil, func, 1)
84
70
  end
85
71
  return ____exports
@@ -0,0 +1,3 @@
1
+ export declare const SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager";
2
+ /** Set this to true to enable more verbosity in the save data manger. */
3
+ export declare const SAVE_DATA_MANAGER_DEBUG = false;
@@ -0,0 +1,5 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ ____exports.SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager"
4
+ ____exports.SAVE_DATA_MANAGER_DEBUG = false
5
+ return ____exports
@@ -3,31 +3,28 @@ local ____lualib = require("lualib_bundle")
3
3
  local Map = ____lualib.Map
4
4
  local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
5
5
  local ____exports = {}
6
- local ____errors = require("errors")
7
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
6
+ local ____featuresInitialized = require("featuresInitialized")
7
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
8
8
  local ____deepCopy = require("functions.deepCopy")
9
9
  local deepCopy = ____deepCopy.deepCopy
10
10
  local SerializationType = ____deepCopy.SerializationType
11
+ local ____constants = require("features.saveDataManager.constants")
12
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
11
13
  local ____main = require("features.saveDataManager.main")
12
- local FEATURE_NAME = ____main.FEATURE_NAME
13
14
  local forceSaveDataManagerLoad = ____main.forceSaveDataManagerLoad
14
15
  local forceSaveDataManagerSave = ____main.forceSaveDataManagerSave
15
- local isSaveDataManagerInitialized = ____main.isSaveDataManagerInitialized
16
16
  local ____maps = require("features.saveDataManager.maps")
17
17
  local saveDataConditionalFuncMap = ____maps.saveDataConditionalFuncMap
18
18
  local saveDataDefaultsMap = ____maps.saveDataDefaultsMap
19
19
  local saveDataMap = ____maps.saveDataMap
20
20
  function ____exports.saveDataManager(self, key, saveData, conditionalFunc)
21
- if not isSaveDataManagerInitialized(nil) then
22
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
23
- error(msg)
24
- end
21
+ errorIfFeaturesNotInitialized(nil, SAVE_DATA_MANAGER_FEATURE_NAME)
25
22
  local keyType = type(key)
26
23
  if keyType ~= "string" then
27
- error("The save data manager requires that keys are strings. You tried to use a key of type: " .. keyType)
24
+ error((("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " requires that keys are strings. You tried to use a key of type: ") .. keyType)
28
25
  end
29
26
  if saveDataMap[key] ~= nil then
30
- error("The save data manager is already managing save data for a key of: " .. key)
27
+ error((("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " is already managing save data for a key of: ") .. key)
31
28
  end
32
29
  saveDataMap[key] = saveData
33
30
  local saveDataKeys = __TS__ObjectKeys(saveData)
@@ -43,17 +40,11 @@ function ____exports.saveDataManager(self, key, saveData, conditionalFunc)
43
40
  end
44
41
  end
45
42
  function ____exports.saveDataManagerSave(self)
46
- if not isSaveDataManagerInitialized(nil) then
47
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
48
- error(msg)
49
- end
43
+ errorIfFeaturesNotInitialized(nil, SAVE_DATA_MANAGER_FEATURE_NAME)
50
44
  forceSaveDataManagerSave(nil)
51
45
  end
52
46
  function ____exports.saveDataManagerLoad(self)
53
- if not isSaveDataManagerInitialized(nil) then
54
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
55
- error(msg)
56
- end
47
+ errorIfFeaturesNotInitialized(nil, SAVE_DATA_MANAGER_FEATURE_NAME)
57
48
  forceSaveDataManagerLoad(nil)
58
49
  end
59
50
  function ____exports.saveDataManagerSetGlobal(self)
@@ -7,8 +7,9 @@ local ____jsonHelpers = require("functions.jsonHelpers")
7
7
  local jsonDecode = ____jsonHelpers.jsonDecode
8
8
  local ____log = require("functions.log")
9
9
  local log = ____log.log
10
- local ____debug = require("features.saveDataManager.debug")
11
- local SAVE_DATA_MANAGER_DEBUG = ____debug.SAVE_DATA_MANAGER_DEBUG
10
+ local ____constants = require("features.saveDataManager.constants")
11
+ local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
12
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
12
13
  local ____merge = require("features.saveDataManager.merge")
13
14
  local merge = ____merge.merge
14
15
  function readSaveDatFile(self, mod)
@@ -60,6 +61,6 @@ function ____exports.loadFromDisk(self, mod, oldSaveData)
60
61
  end
61
62
  ::__continue5::
62
63
  end
63
- log("The save data manager loaded data from the \"save#.dat\" file.")
64
+ log(("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " loaded data from the \"save#.dat\" file.")
64
65
  end
65
66
  return ____exports
@@ -5,8 +5,6 @@ local ____exports = {}
5
5
  local postPlayerInit, preGameExit, postNewLevel, postNewRoomEarly, restoreDefaultsAll, restoreDefaults, clearAndCopyAllElements, mod, loadedDataOnThisRun
6
6
  local ____cachedClasses = require("cachedClasses")
7
7
  local game = ____cachedClasses.game
8
- local ____errors = require("errors")
9
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
10
8
  local ____deepCopy = require("functions.deepCopy")
11
9
  local deepCopy = ____deepCopy.deepCopy
12
10
  local SerializationType = ____deepCopy.SerializationType
@@ -16,6 +14,8 @@ local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
16
14
  local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
17
15
  local ____SaveData = require("types.private.SaveData")
18
16
  local SaveDataKeys = ____SaveData.SaveDataKeys
17
+ local ____constants = require("features.saveDataManager.constants")
18
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
19
19
  local ____load = require("features.saveDataManager.load")
20
20
  local loadFromDisk = ____load.loadFromDisk
21
21
  local ____maps = require("features.saveDataManager.maps")
@@ -26,8 +26,7 @@ local ____save = require("features.saveDataManager.save")
26
26
  local saveToDisk = ____save.saveToDisk
27
27
  function postPlayerInit(self)
28
28
  if mod == nil then
29
- local msg = getUpgradeErrorMsg(nil, ____exports.FEATURE_NAME)
30
- error(msg)
29
+ error(("The mod for the " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " was not initialized.")
31
30
  end
32
31
  if loadedDataOnThisRun then
33
32
  return
@@ -42,8 +41,7 @@ function postPlayerInit(self)
42
41
  end
43
42
  function preGameExit(self)
44
43
  if mod == nil then
45
- local msg = getUpgradeErrorMsg(nil, ____exports.FEATURE_NAME)
46
- error(msg)
44
+ error(("The mod for the " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " was not initialized.")
47
45
  end
48
46
  saveToDisk(nil, mod, saveDataMap, saveDataConditionalFuncMap)
49
47
  restoreDefaultsAll(nil)
@@ -91,7 +89,6 @@ function clearAndCopyAllElements(self, oldTable, newTable)
91
89
  oldTable[key] = value
92
90
  end
93
91
  end
94
- ____exports.FEATURE_NAME = "save data manager"
95
92
  mod = nil
96
93
  loadedDataOnThisRun = false
97
94
  function ____exports.saveDataManagerInit(self, incomingMod)
@@ -101,9 +98,6 @@ function ____exports.saveDataManagerInit(self, incomingMod)
101
98
  mod:AddCallback(ModCallbacks.MC_POST_NEW_LEVEL, postNewLevel)
102
99
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_NEW_ROOM_EARLY, postNewRoomEarly)
103
100
  end
104
- function ____exports.isSaveDataManagerInitialized(self)
105
- return mod ~= nil
106
- end
107
101
  function ____exports.forceSaveDataManagerSave(self)
108
102
  if mod == nil then
109
103
  return
@@ -20,8 +20,8 @@ local clearTable = ____table.clearTable
20
20
  local ____SerializationBrand = require("types.private.SerializationBrand")
21
21
  local isSerializationBrand = ____SerializationBrand.isSerializationBrand
22
22
  local SerializationBrand = ____SerializationBrand.SerializationBrand
23
- local ____debug = require("features.saveDataManager.debug")
24
- local SAVE_DATA_MANAGER_DEBUG = ____debug.SAVE_DATA_MANAGER_DEBUG
23
+ local ____constants = require("features.saveDataManager.constants")
24
+ local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
25
25
  function ____exports.merge(self, oldObject, newTable, traversalDescription)
26
26
  local oldObjectType = type(oldObject)
27
27
  if oldObjectType ~= "table" then
@@ -11,6 +11,8 @@ local ____jsonHelpers = require("functions.jsonHelpers")
11
11
  local jsonEncode = ____jsonHelpers.jsonEncode
12
12
  local ____log = require("functions.log")
13
13
  local log = ____log.log
14
+ local ____constants = require("features.saveDataManager.constants")
15
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
14
16
  function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
15
17
  local allSaveData = {}
16
18
  for subscriberName, saveData in pairs(saveDataMap) do
@@ -40,6 +42,6 @@ function ____exports.saveToDisk(self, mod, saveDataMap, saveDataConditionalFuncM
40
42
  local allSaveData = getAllSaveDataToWriteToDisk(nil, saveDataMap, saveDataConditionalFuncMap)
41
43
  local jsonString = jsonEncode(nil, allSaveData)
42
44
  mod:SaveData(jsonString)
43
- log("The save data manager wrote data to the \"save#.dat\" file.")
45
+ log(("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " wrote data to the \"save#.dat\" file.")
44
46
  end
45
47
  return ____exports
@@ -4,8 +4,8 @@ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
4
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
5
5
  local ____exports = {}
6
6
  local postNPCInitSirenHelper, checkReturnFamiliarToPlayer, blacklistEntryExists, getSirenHelper, v
7
- local ____errors = require("errors")
8
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
7
+ local ____featuresInitialized = require("featuresInitialized")
8
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
9
9
  local ____entity = require("functions.entity")
10
10
  local getEntities = ____entity.getEntities
11
11
  local ____exports = require("features.saveDataManager.exports")
@@ -48,24 +48,20 @@ function getSirenHelper(self, familiar)
48
48
  )
49
49
  end
50
50
  local FEATURE_NAME = "siren helpers"
51
- local initialized = false
52
51
  v = {run = {familiarBlacklist = {}}}
53
52
  function ____exports.sirenHelpersInit(self, mod)
54
- initialized = true
55
53
  saveDataManager(nil, "sirenHelpers", v)
56
54
  mod:AddCallback(ModCallbacks.MC_POST_NPC_INIT, postNPCInitSirenHelper, EntityType.ENTITY_SIREN_HELPER)
57
55
  end
58
56
  function ____exports.setFamiliarNoSirenSteal(self, familiarVariant, familiarSubType)
59
- if not initialized then
60
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
61
- error(msg)
62
- end
57
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
63
58
  if blacklistEntryExists(nil, familiarVariant, familiarSubType) then
64
59
  return
65
60
  end
66
61
  __TS__ArrayPush(v.run.familiarBlacklist, {familiarVariant, familiarSubType})
67
62
  end
68
63
  function ____exports.hasSirenStolenFamiliar(self, familiar)
64
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
69
65
  return getSirenHelper(nil, familiar) ~= nil
70
66
  end
71
67
  return ____exports