isaacscript-common 1.2.138 → 1.2.141

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 (85) hide show
  1. package/dist/callbacks/postSlotRender.d.ts +1 -0
  2. package/dist/callbacks/postSlotRender.lua +73 -0
  3. package/dist/callbacks/subscriptions/postSlotAnimationChanged.d.ts +2 -0
  4. package/dist/callbacks/subscriptions/postSlotAnimationChanged.lua +25 -0
  5. package/dist/constants.d.ts +2 -0
  6. package/dist/features/deployJSONRoom.lua +11 -22
  7. package/dist/features/disableInputs.lua +6 -20
  8. package/dist/features/disableSound.lua +4 -12
  9. package/dist/features/extraConsoleCommands/commands.d.ts +88 -4
  10. package/dist/features/extraConsoleCommands/commands.lua +357 -71
  11. package/dist/features/extraConsoleCommands/init.lua +52 -9
  12. package/dist/features/extraConsoleCommands/v.d.ts +5 -1
  13. package/dist/features/extraConsoleCommands/v.lua +7 -1
  14. package/dist/features/forgottenSwitch.lua +3 -8
  15. package/dist/features/getCollectibleItemPoolType.lua +4 -9
  16. package/dist/features/isPonyActive.lua +3 -8
  17. package/dist/features/preventCollectibleRotate.lua +3 -8
  18. package/dist/features/runInNFrames.lua +6 -20
  19. package/dist/features/saveDataManager/constants.d.ts +3 -0
  20. package/dist/features/saveDataManager/constants.lua +5 -0
  21. package/dist/features/saveDataManager/exports.lua +9 -18
  22. package/dist/features/saveDataManager/load.lua +4 -3
  23. package/dist/features/saveDataManager/main.lua +4 -10
  24. package/dist/features/saveDataManager/merge.lua +2 -2
  25. package/dist/features/saveDataManager/save.lua +3 -1
  26. package/dist/features/sirenHelpers.lua +4 -8
  27. package/dist/featuresInitialized.d.ts +1 -1
  28. package/dist/featuresInitialized.lua +5 -0
  29. package/dist/functions/cards.lua +12 -18
  30. package/dist/functions/challenges.lua +3 -2
  31. package/dist/functions/collectibles.lua +8 -14
  32. package/dist/functions/deepCopy.lua +2 -2
  33. package/dist/functions/log.lua +3 -0
  34. package/dist/functions/map.d.ts +4 -1
  35. package/dist/functions/map.lua +5 -1
  36. package/dist/functions/pills.lua +10 -15
  37. package/dist/functions/player.d.ts +2 -0
  38. package/dist/functions/player.lua +37 -81
  39. package/dist/functions/rooms.lua +4 -5
  40. package/dist/functions/transformations.lua +3 -3
  41. package/dist/functions/trinkets.lua +8 -14
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.lua +16 -0
  44. package/dist/maps/cardDescriptionMap.d.ts +4 -1
  45. package/dist/maps/cardDescriptionMap.lua +103 -102
  46. package/dist/maps/cardNameMap.d.ts +4 -1
  47. package/dist/maps/cardNameMap.lua +103 -102
  48. package/dist/maps/cardTypeMap.d.ts +3 -1
  49. package/dist/maps/cardTypeMap.lua +102 -102
  50. package/dist/maps/challengeNameMap.d.ts +4 -1
  51. package/dist/maps/challengeNameMap.lua +50 -50
  52. package/dist/maps/characterNameMap.d.ts +5 -0
  53. package/dist/maps/characterNameMap.lua +49 -0
  54. package/dist/maps/collectibleDescriptionMap.d.ts +1 -0
  55. package/dist/maps/collectibleDescriptionMap.lua +1 -0
  56. package/dist/maps/collectibleNameMap.d.ts +1 -0
  57. package/dist/maps/collectibleNameMap.lua +1 -0
  58. package/dist/maps/pillEffectClassMap.d.ts +4 -1
  59. package/dist/maps/pillEffectClassMap.lua +56 -55
  60. package/dist/maps/pillEffectNameMap.d.ts +4 -1
  61. package/dist/maps/pillEffectNameMap.lua +55 -55
  62. package/dist/maps/pillEffectTypeMap.d.ts +4 -1
  63. package/dist/maps/pillEffectTypeMap.lua +55 -55
  64. package/dist/maps/roomTypeMap.d.ts +3 -0
  65. package/dist/maps/roomTypeMap.lua +43 -0
  66. package/dist/maps/roomTypeNameMap.d.ts +5 -0
  67. package/dist/maps/roomTypeNameMap.lua +37 -0
  68. package/dist/maps/transformationNameMap.d.ts +4 -1
  69. package/dist/maps/transformationNameMap.lua +19 -20
  70. package/dist/maps/trinketDescriptionMap.d.ts +1 -0
  71. package/dist/maps/trinketDescriptionMap.lua +1 -0
  72. package/dist/maps/trinketNameMap.d.ts +1 -0
  73. package/dist/maps/trinketNameMap.lua +1 -0
  74. package/dist/types/CallbackParametersCustom.d.ts +5 -0
  75. package/dist/types/CardType.d.ts +10 -8
  76. package/dist/types/CardType.lua +9 -7
  77. package/dist/types/ModCallbacksCustom.d.ts +10 -9
  78. package/dist/types/ModCallbacksCustom.lua +11 -9
  79. package/dist/types/ModUpgraded.lua +8 -0
  80. package/dist/types/PillEffectClass.d.ts +11 -5
  81. package/dist/types/PillEffectClass.lua +8 -5
  82. package/dist/types/PillEffectType.d.ts +10 -4
  83. package/dist/types/PillEffectType.lua +7 -4
  84. package/dist/upgradeMod.lua +3 -3
  85. package/package.json +1 -1
@@ -3,7 +3,7 @@ local ____lualib = require("lualib_bundle")
3
3
  local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
- local postUpdate, evaluateCacheSpeed, entityTakeDmgPlayer, executeCmd, postFireTear, commandFunctionsMap
6
+ local featureEnabled, postUpdate, evaluateCacheFireDelay, evaluateCacheSpeed, entityTakeDmgPlayer, postCurseEval, executeCmd, postFireTear, commandFunctionsMap, initialized
7
7
  local ____constants = require("constants")
8
8
  local MAX_SPEED_STAT = ____constants.MAX_SPEED_STAT
9
9
  local ____map = require("functions.map")
@@ -15,12 +15,20 @@ local saveDataManager = ____exports.saveDataManager
15
15
  local commands = require("features.extraConsoleCommands.commands")
16
16
  local ____v = require("features.extraConsoleCommands.v")
17
17
  local v = ____v.default
18
+ function featureEnabled(self)
19
+ return initialized
20
+ end
18
21
  function postUpdate(self)
19
22
  if v.run.spamBloodRights then
20
23
  local player = Isaac.GetPlayer()
21
24
  player:UseActiveItem(CollectibleType.COLLECTIBLE_BLOOD_RIGHTS)
22
25
  end
23
26
  end
27
+ function evaluateCacheFireDelay(self, player)
28
+ if v.run.maxTears then
29
+ player.FireDelay = 1
30
+ end
31
+ end
24
32
  function evaluateCacheSpeed(self, player)
25
33
  if v.run.maxSpeed then
26
34
  player.MoveSpeed = MAX_SPEED_STAT
@@ -32,13 +40,18 @@ function entityTakeDmgPlayer(self)
32
40
  end
33
41
  return nil
34
42
  end
43
+ function postCurseEval(self, curses)
44
+ return v.persistent.disableCurses and LevelCurse.CURSE_NONE or curses
45
+ end
35
46
  function executeCmd(self, command, params)
36
- local commandFunction = getMapPartialMatch(nil, command, commandFunctionsMap)
37
- if commandFunction == nil then
47
+ local resultTuple = getMapPartialMatch(nil, command, commandFunctionsMap)
48
+ if resultTuple == nil then
38
49
  printConsole(nil, "That is an invalid console command.")
39
- else
40
- commandFunction(nil, params)
50
+ return
41
51
  end
52
+ local commandName, commandFunction = table.unpack(resultTuple)
53
+ printConsole(nil, "Command: " .. commandName)
54
+ commandFunction(nil, params)
42
55
  end
43
56
  function postFireTear(self, tear)
44
57
  if v.run.chaosCardTears then
@@ -50,13 +63,15 @@ function postFireTear(self, tear)
50
63
  end
51
64
  end
52
65
  commandFunctionsMap = __TS__New(Map)
53
- local initialized = false
66
+ initialized = false
54
67
  function ____exports.enableExtraConsoleCommands(self, mod)
55
68
  initialized = true
56
- saveDataManager(nil, "extraConsoleCommands", v)
69
+ saveDataManager(nil, "extraConsoleCommands", v, featureEnabled)
57
70
  mod:AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate)
71
+ mod:AddCallback(ModCallbacks.MC_EVALUATE_CACHE, evaluateCacheFireDelay, CacheFlag.CACHE_FIREDELAY)
58
72
  mod:AddCallback(ModCallbacks.MC_EVALUATE_CACHE, evaluateCacheSpeed, CacheFlag.CACHE_SPEED)
59
73
  mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, entityTakeDmgPlayer, EntityType.ENTITY_PLAYER)
74
+ mod:AddCallback(ModCallbacks.MC_POST_CURSE_EVAL, postCurseEval)
60
75
  mod:AddCallback(ModCallbacks.MC_EXECUTE_CMD, executeCmd)
61
76
  mod:AddCallback(ModCallbacks.MC_POST_FIRE_TEAR, postFireTear)
62
77
  end
@@ -78,8 +93,10 @@ function ____exports.removeConsoleCommand(self, commandName)
78
93
  end
79
94
  commandFunctionsMap:delete(commandName)
80
95
  end
96
+ commandFunctionsMap:set("addcharges", commands.addCharges)
81
97
  commandFunctionsMap:set("angel", commands.angel)
82
98
  commandFunctionsMap:set("ascent", commands.ascent)
99
+ commandFunctionsMap:set("bedroom", commands.bedroom)
83
100
  commandFunctionsMap:set("bh", commands.bh)
84
101
  commandFunctionsMap:set("blackhearts", commands.blackHearts)
85
102
  commandFunctionsMap:set("blackmarket", commands.blackMarket)
@@ -88,6 +105,7 @@ commandFunctionsMap:set("bomb", commands.bomb)
88
105
  commandFunctionsMap:set("bombs", commands.bombs)
89
106
  commandFunctionsMap:set("bonehearts", commands.boneHearts)
90
107
  commandFunctionsMap:set("boss", commands.boss)
108
+ commandFunctionsMap:set("bossrush", commands.bossRush)
91
109
  commandFunctionsMap:set("bm", commands.bm)
92
110
  commandFunctionsMap:set("brokenhearts", commands.brokenHearts)
93
111
  commandFunctionsMap:set("card", commands.card)
@@ -95,6 +113,8 @@ commandFunctionsMap:set("cards", commands.cards)
95
113
  commandFunctionsMap:set("cc", commands.cc)
96
114
  commandFunctionsMap:set("chaoscardtears", commands.chaosCardTears)
97
115
  commandFunctionsMap:set("character", commands.characterCommand)
116
+ commandFunctionsMap:set("charge", commands.charge)
117
+ commandFunctionsMap:set("cleanbedroom", commands.cleanBedroom)
98
118
  commandFunctionsMap:set("coin", commands.coin)
99
119
  commandFunctionsMap:set("coins", commands.coins)
100
120
  commandFunctionsMap:set("crawlspace", commands.crawlspace)
@@ -103,21 +123,32 @@ commandFunctionsMap:set("d20", commands.d20)
103
123
  commandFunctionsMap:set("damage", commands.damage)
104
124
  commandFunctionsMap:set("dd", commands.dd)
105
125
  commandFunctionsMap:set("devil", commands.devil)
126
+ commandFunctionsMap:set("dirtybedroom", commands.dirtyBedroom)
127
+ commandFunctionsMap:set("disablecurses", commands.disableCurses)
106
128
  commandFunctionsMap:set("down", commands.down)
129
+ commandFunctionsMap:set("dungeon", commands.dungeon)
107
130
  commandFunctionsMap:set("effects", commands.effects)
108
131
  commandFunctionsMap:set("eh", commands.eh)
109
132
  commandFunctionsMap:set("error", commands.error)
110
133
  commandFunctionsMap:set("eternalhearts", commands.eternalHearts)
111
134
  commandFunctionsMap:set("fool", commands.fool)
135
+ commandFunctionsMap:set("getposition", commands.getPosition)
136
+ commandFunctionsMap:set("gigabomb", commands.gigaBomb)
112
137
  commandFunctionsMap:set("goldbomb", commands.goldBomb)
113
138
  commandFunctionsMap:set("goldenbomb", commands.goldenBomb)
114
- commandFunctionsMap:set("goldkey", commands.goldKey)
139
+ commandFunctionsMap:set("goldenhearts", commands.goldenHearts)
115
140
  commandFunctionsMap:set("goldenkey", commands.goldenKey)
141
+ commandFunctionsMap:set("goldhearts", commands.goldHearts)
142
+ commandFunctionsMap:set("goldkey", commands.goldKey)
143
+ commandFunctionsMap:set("grid", commands.grid)
144
+ commandFunctionsMap:set("grid2", commands.grid2)
116
145
  commandFunctionsMap:set("h", commands.h)
117
146
  commandFunctionsMap:set("hearts", commands.hearts)
147
+ commandFunctionsMap:set("hitboxes", commands.hitboxes)
118
148
  commandFunctionsMap:set("iamerror", commands.IAMERROR)
119
149
  commandFunctionsMap:set("key", commands.key)
120
150
  commandFunctionsMap:set("keys", commands.keys)
151
+ commandFunctionsMap:set("library", commands.library)
121
152
  commandFunctionsMap:set("list", commands.list)
122
153
  commandFunctionsMap:set("listall", commands.listAll)
123
154
  commandFunctionsMap:set("listgrid", commands.listGrid)
@@ -126,17 +157,25 @@ commandFunctionsMap:set("lowhp", commands.lowHP)
126
157
  commandFunctionsMap:set("luck", commands.luck)
127
158
  commandFunctionsMap:set("maxhearts", commands.maxHearts)
128
159
  commandFunctionsMap:set("mh", commands.mh)
160
+ commandFunctionsMap:set("miniboss", commands.miniboss)
161
+ commandFunctionsMap:set("nocurses", commands.noCurses)
129
162
  commandFunctionsMap:set("pill", commands.pill)
130
163
  commandFunctionsMap:set("pills", commands.pills)
131
164
  commandFunctionsMap:set("planetarium", commands.planetarium)
165
+ commandFunctionsMap:set("playsound", commands.playSound)
132
166
  commandFunctionsMap:set("pocket", commands.pocket)
167
+ commandFunctionsMap:set("poopMana", commands.poopMana)
133
168
  commandFunctionsMap:set("position", commands.positionCommand)
134
169
  commandFunctionsMap:set("redhearts", commands.redHearts)
135
170
  commandFunctionsMap:set("rh", commands.rh)
136
171
  commandFunctionsMap:set("room", commands.roomCommand)
137
172
  commandFunctionsMap:set("rottenhearts", commands.rottenHearts)
138
173
  commandFunctionsMap:set("s", commands.s)
174
+ commandFunctionsMap:set("sacrifice", commands.sacrifice)
175
+ commandFunctionsMap:set("secret", commands.secret)
139
176
  commandFunctionsMap:set("seeds", commands.seeds)
177
+ commandFunctionsMap:set("setcharges", commands.setCharges)
178
+ commandFunctionsMap:set("setposition", commands.setPosition)
140
179
  commandFunctionsMap:set("sh", commands.sh)
141
180
  commandFunctionsMap:set("shop", commands.shop)
142
181
  commandFunctionsMap:set("smelt", commands.smelt)
@@ -145,9 +184,13 @@ commandFunctionsMap:set("soulhearts", commands.soulHearts)
145
184
  commandFunctionsMap:set("sound", commands.sound)
146
185
  commandFunctionsMap:set("sounds", commands.sounds)
147
186
  commandFunctionsMap:set("spam", commands.spam)
187
+ commandFunctionsMap:set("spawngoldentrinket", commands.spawnGoldenTrinket)
148
188
  commandFunctionsMap:set("speed", commands.speed)
189
+ commandFunctionsMap:set("supersecret", commands.superSecret)
149
190
  commandFunctionsMap:set("startingroom", commands.startingRoom)
191
+ commandFunctionsMap:set("tears", commands.tears)
150
192
  commandFunctionsMap:set("trapdoor", commands.trapdoorCommand)
151
193
  commandFunctionsMap:set("treasure", commands.treasure)
152
- commandFunctionsMap:set("ultra", commands.ultra)
194
+ commandFunctionsMap:set("ultrasecret", commands.ultraSecret)
195
+ commandFunctionsMap:set("warp", commands.warp)
153
196
  return ____exports
@@ -1,9 +1,13 @@
1
1
  declare const v: {
2
+ persistent: {
3
+ disableCurses: boolean;
4
+ };
2
5
  run: {
3
6
  chaosCardTears: boolean;
4
7
  spamBloodRights: boolean;
5
- maxSpeed: boolean;
6
8
  maxDamage: boolean;
9
+ maxSpeed: boolean;
10
+ maxTears: boolean;
7
11
  };
8
12
  };
9
13
  export default v;
@@ -1,5 +1,11 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- local v = {run = {chaosCardTears = false, spamBloodRights = false, maxSpeed = false, maxDamage = false}}
3
+ local v = {persistent = {disableCurses = false}, run = {
4
+ chaosCardTears = false,
5
+ spamBloodRights = false,
6
+ maxDamage = false,
7
+ maxSpeed = false,
8
+ maxTears = false
9
+ }}
4
10
  ____exports.default = v
5
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
@@ -1 +1 @@
1
- export {};
1
+ export declare function errorIfFeaturesNotInitialized(featureName: string): void;
@@ -7,4 +7,9 @@ end
7
7
  function ____exports.setFeaturesInitialized(self)
8
8
  featuresInitialized = true
9
9
  end
10
+ function ____exports.errorIfFeaturesNotInitialized(self, featureName)
11
+ if not ____exports.areFeaturesInitialized(nil) then
12
+ error(("The " .. featureName) .. " is not initialized. You must first upgrade your mod object by calling the \"upgradeMod\" function.")
13
+ end
14
+ end
10
15
  return ____exports