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,8 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to spawn a custom muting all sound effects and music.
4
+ *
5
+ * Use this function to set things back to normal after having used [[`disableAllSounds`]].
6
+ *
7
+ */
8
+ export declare function spawnCustomDoor(_customDoorType: int, _anm2: string, _slot: DoorSlot): void;
@@ -0,0 +1,35 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local Set = ____lualib.Set
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ local hasSubscriptions, postRender
7
+ local ____exports = require("features.saveDataManager.exports")
8
+ local saveDataManager = ____exports.saveDataManager
9
+ local ____doors = require("functions.doors")
10
+ local getDoors = ____doors.getDoors
11
+ local ____postCustomDoorEnter = require("callbacks.subscriptions.postCustomDoorEnter")
12
+ local postCustomDoorEnterFire = ____postCustomDoorEnter.postCustomDoorEnterFire
13
+ local postCustomDoorEnterHasSubscriptions = ____postCustomDoorEnter.postCustomDoorEnterHasSubscriptions
14
+ function hasSubscriptions(self)
15
+ return postCustomDoorEnterHasSubscriptions(nil)
16
+ end
17
+ function postRender(self)
18
+ if not hasSubscriptions(nil) then
19
+ return
20
+ end
21
+ local doors = getDoors(nil)
22
+ if #doors == 0 then
23
+ return
24
+ end
25
+ local door = doors[1]
26
+ postCustomDoorEnterFire(nil, door)
27
+ end
28
+ local v = {run = {disableSoundSet = __TS__New(Set)}}
29
+ function ____exports.postCustomDoorEnterCallbackInit(self, mod)
30
+ saveDataManager(nil, "postCustomDoorEnter", v, hasSubscriptions)
31
+ mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
32
+ end
33
+ function ____exports.spawnCustomDoor(self, _customDoorType, _anm2, _slot)
34
+ end
35
+ return ____exports
@@ -3,16 +3,14 @@ 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 hasSubscriptions, postPEffectUpdateReordered, getCurrentHealthValue, v
6
+ local hasSubscriptions, postPEffectUpdateReordered, v
7
7
  local ____exports = require("features.saveDataManager.exports")
8
8
  local saveDataManager = ____exports.saveDataManager
9
9
  local ____player = require("functions.player")
10
- local getBlackHearts = ____player.getBlackHearts
11
- local getHearts = ____player.getHearts
12
10
  local getPlayerIndex = ____player.getPlayerIndex
13
- local getSoulHearts = ____player.getSoulHearts
11
+ local ____playerHealth = require("functions.playerHealth")
12
+ local getPlayerHealthType = ____playerHealth.getPlayerHealthType
14
13
  local ____utils = require("functions.utils")
15
- local ensureAllCases = ____utils.ensureAllCases
16
14
  local getEnumValues = ____utils.getEnumValues
17
15
  local ____DefaultMap = require("types.DefaultMap")
18
16
  local DefaultMap = ____DefaultMap.DefaultMap
@@ -34,7 +32,7 @@ function postPEffectUpdateReordered(self, player)
34
32
  local playerHealthMap = v.run.playersHealthMap:getAndSetDefault(playerIndex)
35
33
  for ____, healthType in ipairs(getEnumValues(nil, HealthType)) do
36
34
  local storedHealthValue = playerHealthMap:get(healthType)
37
- local currentHealthValue = getCurrentHealthValue(nil, player, healthType)
35
+ local currentHealthValue = getPlayerHealthType(nil, player, healthType)
38
36
  playerHealthMap:set(healthType, currentHealthValue)
39
37
  if storedHealthValue ~= nil and storedHealthValue ~= currentHealthValue then
40
38
  local amount = currentHealthValue - storedHealthValue
@@ -42,64 +40,6 @@ function postPEffectUpdateReordered(self, player)
42
40
  end
43
41
  end
44
42
  end
45
- function getCurrentHealthValue(self, player, healthType)
46
- repeat
47
- local ____switch11 = healthType
48
- local ____cond11 = ____switch11 == HealthType.RED
49
- if ____cond11 then
50
- do
51
- return getHearts(nil, player)
52
- end
53
- end
54
- ____cond11 = ____cond11 or ____switch11 == HealthType.SOUL
55
- if ____cond11 then
56
- do
57
- return getSoulHearts(nil, player)
58
- end
59
- end
60
- ____cond11 = ____cond11 or ____switch11 == HealthType.ETERNAL
61
- if ____cond11 then
62
- do
63
- return player:GetEternalHearts()
64
- end
65
- end
66
- ____cond11 = ____cond11 or ____switch11 == HealthType.BLACK
67
- if ____cond11 then
68
- do
69
- return getBlackHearts(nil, player)
70
- end
71
- end
72
- ____cond11 = ____cond11 or ____switch11 == HealthType.GOLDEN
73
- if ____cond11 then
74
- do
75
- return player:GetGoldenHearts()
76
- end
77
- end
78
- ____cond11 = ____cond11 or ____switch11 == HealthType.BONE
79
- if ____cond11 then
80
- do
81
- return player:GetBoneHearts()
82
- end
83
- end
84
- ____cond11 = ____cond11 or ____switch11 == HealthType.ROTTEN
85
- if ____cond11 then
86
- do
87
- return player:GetRottenHearts()
88
- end
89
- end
90
- ____cond11 = ____cond11 or ____switch11 == HealthType.MAX_HEARTS
91
- if ____cond11 then
92
- do
93
- return player:GetMaxHearts()
94
- end
95
- end
96
- do
97
- do
98
- return ensureAllCases(nil, healthType)
99
- end
100
- end
101
- until true
102
- end
103
43
  v = {run = {playersHealthMap = __TS__New(
104
44
  DefaultMap,
105
45
  function() return __TS__New(Map) end
@@ -0,0 +1,2 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare type PostCustomDoorEnterCallbackType = (door: GridEntityDoor) => void;
@@ -0,0 +1,25 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
+ local ____exports = {}
5
+ local subscriptions = {}
6
+ function ____exports.postCustomDoorEnterHasSubscriptions(self)
7
+ return #subscriptions > 0
8
+ end
9
+ function ____exports.postCustomDoorEnterRegister(self, callback, doorVariant)
10
+ __TS__ArrayPush(subscriptions, {callback, doorVariant})
11
+ end
12
+ function ____exports.postCustomDoorEnterFire(self, door)
13
+ for ____, ____value in ipairs(subscriptions) do
14
+ local callback = ____value[1]
15
+ local doorVariant = ____value[2]
16
+ do
17
+ if doorVariant ~= nil and doorVariant ~= door:GetVariant() then
18
+ goto __continue5
19
+ end
20
+ callback(nil, door)
21
+ end
22
+ ::__continue5::
23
+ end
24
+ end
25
+ return ____exports
@@ -81,6 +81,11 @@ export declare const MAX_NUM_DOORS = 8;
81
81
  export declare const MAX_NUM_FAMILIARS = 64;
82
82
  /** The game can only handle up to four different players. */
83
83
  export declare const MAX_NUM_INPUTS = 4;
84
+ /**
85
+ * The maximum speed stat that a player can have. Any additional speed beyond this will not take
86
+ * effect.
87
+ */
88
+ export declare const MAX_SPEED_STAT = 2;
84
89
  /** With Birthright, it is possible for Magdalene to have 18 heart containers. */
85
90
  export declare const MAX_PLAYER_HEART_CONTAINERS = 18;
86
91
  export declare const MAX_PLAYER_POCKET_ITEM_SLOTS = 4;
@@ -121,6 +126,8 @@ export declare const PILL_COLOR_MASK = 2047;
121
126
  export declare const SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES: ReadonlySet<CollectibleType>;
122
127
  export declare const STORY_BOSSES: ReadonlySet<EntityType>;
123
128
  /**
129
+ * Add this to a `TrinketType` to get the corresponding golden trinket type.
130
+ *
124
131
  * In vanilla, this is part of the `TrinketType` enum, but we implement it as a constant in
125
132
  * IsaacScript since it is not a real trinket type.
126
133
  *
@@ -92,6 +92,7 @@ ____exports.LOST_STYLE_PLAYER_TYPES = __TS__New(Set, {
92
92
  ____exports.MAX_NUM_DOORS = 8
93
93
  ____exports.MAX_NUM_FAMILIARS = 64
94
94
  ____exports.MAX_NUM_INPUTS = 4
95
+ ____exports.MAX_SPEED_STAT = 2
95
96
  ____exports.MAX_PLAYER_HEART_CONTAINERS = 18
96
97
  ____exports.MAX_PLAYER_POCKET_ITEM_SLOTS = 4
97
98
  ____exports.MAX_PLAYER_SPEED_IN_UNITS = 9.8
@@ -6,11 +6,11 @@ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
6
  local Map = ____lualib.Map
7
7
  local __TS__Iterator = ____lualib.__TS__Iterator
8
8
  local ____exports = {}
9
- local postNewRoom, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, initialized, v
9
+ local postNewRoom, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, v
10
10
  local ____cachedClasses = require("cachedClasses")
11
11
  local game = ____cachedClasses.game
12
- local ____errors = require("errors")
13
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
12
+ local ____featuresInitialized = require("featuresInitialized")
13
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
14
14
  local ____entity = require("functions.entity")
15
15
  local removeAllMatchingEntities = ____entity.removeAllMatchingEntities
16
16
  local ____entitySpecific = require("functions.entitySpecific")
@@ -80,10 +80,7 @@ function respawnPersistentEntities(self)
80
80
  end
81
81
  end
82
82
  function ____exports.emptyRoom(self, fillWithDecorations)
83
- if not initialized then
84
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
85
- error(msg)
86
- end
83
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
87
84
  local roomListIndex = getRoomListIndex(nil)
88
85
  v.level.deployedRoomListIndexes:add(roomListIndex)
89
86
  removeAllBombs(nil)
@@ -103,10 +100,10 @@ function removeSpecificNPCs(self)
103
100
  for ____, npc in ipairs(getNPCs(nil)) do
104
101
  do
105
102
  if NPC_TYPES_TO_NOT_REMOVE:has(npc.Type) then
106
- goto __continue27
103
+ goto __continue24
107
104
  end
108
105
  if npc:HasEntityFlags(EntityFlag.FLAG_CHARM) or npc:HasEntityFlags(EntityFlag.FLAG_FRIENDLY) or npc:HasEntityFlags(EntityFlag.FLAG_PERSISTENT) then
109
- goto __continue27
106
+ goto __continue24
110
107
  end
111
108
  npc:ClearEntityFlags(EntityFlag.FLAG_APPEAR)
112
109
  npc:Remove()
@@ -115,7 +112,7 @@ function removeSpecificNPCs(self)
115
112
  room:SetGridPath(gridIndex, 0)
116
113
  end
117
114
  end
118
- ::__continue27::
115
+ ::__continue24::
119
116
  end
120
117
  end
121
118
  function fillRoomWithDecorations(self)
@@ -127,7 +124,7 @@ function fillRoomWithDecorations(self)
127
124
  do
128
125
  local existingGridEntity = room:GetGridEntity(gridIndex)
129
126
  if existingGridEntity ~= nil then
130
- goto __continue33
127
+ goto __continue30
131
128
  end
132
129
  local position = room:GetGridPosition(gridIndex)
133
130
  local decoration = Isaac.GridSpawn(GridEntityType.GRID_DECORATION, 0, position, true)
@@ -136,7 +133,7 @@ function fillRoomWithDecorations(self)
136
133
  end
137
134
  __TS__ArrayPush(decorationGridIndexes, gridIndex)
138
135
  end
139
- ::__continue33::
136
+ ::__continue30::
140
137
  end
141
138
  end
142
139
  function spawnAllEntities(self, jsonRoom, seed, verbose)
@@ -391,7 +388,6 @@ end
391
388
  FEATURE_NAME = "JSON room deployer"
392
389
  NPC_TYPES_TO_NOT_REMOVE = __TS__New(Set, {EntityType.ENTITY_DARK_ESAU})
393
390
  PERSISTENT_ENTITY_TYPES = __TS__New(Set, {EntityType.ENTITY_WALL_HUGGER})
394
- initialized = false
395
391
  v = {level = {
396
392
  deployedRoomListIndexes = __TS__New(Set),
397
393
  roomToPersistentEntitiesMap = __TS__New(
@@ -404,7 +400,6 @@ v = {level = {
404
400
  )
405
401
  }}
406
402
  function ____exports.deployJSONRoomInit(self, mod)
407
- initialized = true
408
403
  saveDataManager(nil, "deployJSONRoom", v)
409
404
  mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, postNewRoom)
410
405
  end
@@ -415,10 +410,7 @@ function ____exports.deployJSONRoom(self, jsonRoom, seed, verbose)
415
410
  if verbose == nil then
416
411
  verbose = false
417
412
  end
418
- if not initialized then
419
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
420
- error(msg)
421
- end
413
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
422
414
  if verbose then
423
415
  log("Starting to empty the room of entities and grid entities.")
424
416
  end
@@ -444,10 +436,7 @@ function ____exports.deployRandomJSONRoom(self, jsonRooms, seed, verbose)
444
436
  if verbose == nil then
445
437
  verbose = false
446
438
  end
447
- if not initialized then
448
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
449
- error(msg)
450
- end
439
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
451
440
  local randomJSONRoom = getRandomJSONRoom(nil, jsonRooms, seed, verbose)
452
441
  if verbose then
453
442
  log((((((("Randomly chose JSON room " .. randomJSONRoom["$"].type) .. ".") .. randomJSONRoom["$"].variant) .. ".") .. randomJSONRoom["$"].subtype) .. " with name: ") .. randomJSONRoom["$"].name)
@@ -6,8 +6,8 @@ local __TS__Iterator = ____lualib.__TS__Iterator
6
6
  local Set = ____lualib.Set
7
7
  local ____exports = {}
8
8
  local isActionPressed, isActionTriggered, getActionValue, getReturnValue, v
9
- local ____errors = require("errors")
10
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
9
+ local ____featuresInitialized = require("featuresInitialized")
10
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
11
11
  local ____input = require("functions.input")
12
12
  local getMoveActions = ____input.getMoveActions
13
13
  local getShootActions = ____input.getShootActions
@@ -43,31 +43,23 @@ function getReturnValue(self, buttonAction, booleanCallback)
43
43
  return nil
44
44
  end
45
45
  local FEATURE_NAME = "input disabler"
46
- local initialized = false
47
46
  v = {run = {
48
47
  disableInputsWithWhitelistMap = __TS__New(Map),
49
48
  enableInputsWithBlacklistMap = __TS__New(Map)
50
49
  }}
51
50
  function ____exports.disableInputsInit(self, mod)
52
- initialized = true
53
51
  saveDataManager(nil, "disableInputs", v)
54
52
  mod:AddCallback(ModCallbacks.MC_INPUT_ACTION, isActionPressed, InputHook.IS_ACTION_PRESSED)
55
53
  mod:AddCallback(ModCallbacks.MC_INPUT_ACTION, isActionTriggered, InputHook.IS_ACTION_TRIGGERED)
56
54
  mod:AddCallback(ModCallbacks.MC_INPUT_ACTION, getActionValue, InputHook.GET_ACTION_VALUE)
57
55
  end
58
56
  function ____exports.enableAllInputs(self, key)
59
- if not initialized then
60
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
61
- error(msg)
62
- end
57
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
63
58
  v.run.disableInputsWithWhitelistMap:delete(key)
64
59
  v.run.enableInputsWithBlacklistMap:delete(key)
65
60
  end
66
61
  function ____exports.disableAllInputs(self, key)
67
- if not initialized then
68
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
69
- error(msg)
70
- end
62
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
71
63
  v.run.disableInputsWithWhitelistMap:set(
72
64
  key,
73
65
  __TS__New(Set)
@@ -75,18 +67,12 @@ function ____exports.disableAllInputs(self, key)
75
67
  v.run.enableInputsWithBlacklistMap:delete(key)
76
68
  end
77
69
  function ____exports.enableAllInputsExceptFor(self, key, blacklist)
78
- if not initialized then
79
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
80
- error(msg)
81
- end
70
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
82
71
  v.run.disableInputsWithWhitelistMap:delete(key)
83
72
  v.run.enableInputsWithBlacklistMap:set(key, blacklist)
84
73
  end
85
74
  function ____exports.disableAllInputsExceptFor(self, key, whitelist)
86
- if not initialized then
87
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
88
- error(msg)
89
- end
75
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
90
76
  v.run.disableInputsWithWhitelistMap:set(key, whitelist)
91
77
  v.run.enableInputsWithBlacklistMap:delete(key)
92
78
  end
@@ -6,8 +6,8 @@ local ____exports = {}
6
6
  local postRender, v
7
7
  local ____cachedClasses = require("cachedClasses")
8
8
  local musicManager = ____cachedClasses.musicManager
9
- local ____errors = require("errors")
10
- local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
9
+ local ____featuresInitialized = require("featuresInitialized")
10
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
11
11
  local ____sound = require("functions.sound")
12
12
  local stopAllSoundEffects = ____sound.stopAllSoundEffects
13
13
  local ____exports = require("features.saveDataManager.exports")
@@ -19,19 +19,14 @@ function postRender(self)
19
19
  stopAllSoundEffects(nil)
20
20
  end
21
21
  local FEATURE_NAME = "sound disabler"
22
- local initialized = false
23
22
  local musicWasEnabled = false
24
23
  v = {run = {disableSoundSet = __TS__New(Set)}}
25
24
  function ____exports.disableSoundsInit(self, mod)
26
- initialized = true
27
25
  saveDataManager(nil, "disableSounds", v)
28
26
  mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
29
27
  end
30
28
  function ____exports.enableAllSound(self, key)
31
- if not initialized then
32
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
33
- error(msg)
34
- end
29
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
35
30
  if not v.run.disableSoundSet:has(key) then
36
31
  return
37
32
  end
@@ -42,10 +37,7 @@ function ____exports.enableAllSound(self, key)
42
37
  stopAllSoundEffects(nil)
43
38
  end
44
39
  function ____exports.disableAllSound(self, key)
45
- if not initialized then
46
- local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
47
- error(msg)
48
- end
40
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
49
41
  if v.run.disableSoundSet.size == 0 then
50
42
  musicWasEnabled = musicManager:IsEnabled()
51
43
  end