isaacscript-common 1.0.459 → 1.0.460

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.
@@ -6,7 +6,8 @@ export declare function disableInputsInit(mod: ModUpgraded): void;
6
6
  export declare function enableAllInputs(): void;
7
7
  /**
8
8
  * Helper function to disable all inputs.
9
- * This is useful because `EntityPlayer.ControlsEnabled` is not very reliable.
9
+ * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
10
+ * conditions.
10
11
  *
11
12
  * Call `enableAllInputs()` to set things back to normal.
12
13
  *
@@ -16,7 +17,8 @@ export declare function enableAllInputs(): void;
16
17
  export declare function disableAllInputs(): void;
17
18
  /**
18
19
  * Helper function to enable all inputs besides the ones provided.
19
- * This is useful because `EntityPlayer.ControlsEnabled` is not very reliable.
20
+ * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
21
+ * conditions.
20
22
  *
21
23
  * Call `enableAllInputs()` to set things back to normal.
22
24
  *
@@ -26,7 +28,8 @@ export declare function disableAllInputs(): void;
26
28
  export declare function enableAllInputsExceptFor(blacklist: Set<ButtonAction>): void;
27
29
  /**
28
30
  * Helper function to disable all inputs besides the ones provided.
29
- * This is useful because `EntityPlayer.ControlsEnabled` is not very reliable.
31
+ * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
32
+ * conditions.
30
33
  *
31
34
  * Call `enableAllInputs()` to set things back to normal.
32
35
  *
@@ -37,7 +40,8 @@ export declare function disableAllInputsExceptFor(whitelist: Set<ButtonAction>):
37
40
  /**
38
41
  * Helper function to disable only the inputs used for moving the character (or moving the cursor in
39
42
  * the UI).
40
- * This is useful because `EntityPlayer.ControlsEnabled` is not very reliable.
43
+ * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
44
+ * conditions.
41
45
  *
42
46
  * Call `enableInputs()` to set things back to normal.
43
47
  *
@@ -47,7 +51,8 @@ export declare function disableAllInputsExceptFor(whitelist: Set<ButtonAction>):
47
51
  export declare function disableMovementInputs(): void;
48
52
  /**
49
53
  * Helper function to disable only the inputs used for shooting tears.
50
- * This is useful because `EntityPlayer.ControlsEnabled` is not very reliable.
54
+ * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
55
+ * conditions.
51
56
  *
52
57
  * Call `enableInputs()` to set things back to normal.
53
58
  *
@@ -12,7 +12,7 @@ function isActionTriggered(self, _entity, _inputHook, buttonAction)
12
12
  end
13
13
  return nil
14
14
  end
15
- local FEATURE_NAME = "Forgotten switcher"
15
+ local FEATURE_NAME = "forgotten switcher"
16
16
  local initialized = false
17
17
  v = {run = {shouldSwitch = false}}
18
18
  function ____exports.forgottenSwitchInit(self, mod)
@@ -0,0 +1,10 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ import { ModUpgraded } from "../types/ModUpgraded";
3
+ /** @hidden */
4
+ export declare function getCollectibleItemPoolTypeInit(mod: ModUpgraded): void;
5
+ /**
6
+ * Helper function to get the item pool type that a given collectible came from. Since there is no
7
+ * native method in the API to get this, IsaacScript listens in the PreGetCollectible callback for
8
+ * item pool types, and then assumes that the next spawned collectible will match.
9
+ */
10
+ export declare function getCollectibleItemPoolType(collectible: EntityPickup): ItemPoolType;
@@ -0,0 +1,64 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
3
+ local ____exports = {}
4
+ local postPickupInitCollectible, preGetCollectible, v
5
+ local ____errors = require("errors")
6
+ local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
7
+ local ____array = require("functions.array")
8
+ local arrayEmpty = ____array.arrayEmpty
9
+ local ____rooms = require("functions.rooms")
10
+ local getRoomIndex = ____rooms.getRoomIndex
11
+ local getRoomItemPoolType = ____rooms.getRoomItemPoolType
12
+ local getRoomVisitedCount = ____rooms.getRoomVisitedCount
13
+ local ____exports = require("features.saveDataManager.exports")
14
+ local saveDataManager = ____exports.saveDataManager
15
+ function postPickupInitCollectible(self, pickup)
16
+ local itemPoolType = __TS__ArrayShift(v.run.collectibleQueue)
17
+ if itemPoolType == nil then
18
+ return
19
+ end
20
+ local ptrHash = GetPtrHash(pickup)
21
+ v.run.collectibleItemPoolTypeMap:set(ptrHash, itemPoolType)
22
+ end
23
+ function preGetCollectible(self, itemPoolType, _decrease, _seed)
24
+ local roomIndex = getRoomIndex(nil)
25
+ local roomVisitedCount = getRoomVisitedCount(nil)
26
+ if (roomIndex ~= v.run.currentRoomIndex) or (roomVisitedCount ~= v.run.currentRoomVisitedCount) then
27
+ v.run.currentRoomIndex = roomIndex
28
+ v.run.currentRoomVisitedCount = roomVisitedCount
29
+ arrayEmpty(nil, v.run.collectibleQueue)
30
+ v.run.collectibleItemPoolTypeMap:clear()
31
+ end
32
+ __TS__ArrayPush(v.run.collectibleQueue, itemPoolType)
33
+ end
34
+ local FEATURE_NAME = "get collectible item pool type"
35
+ local initialized = false
36
+ v = {
37
+ run = {
38
+ collectibleQueue = {},
39
+ collectibleItemPoolTypeMap = __TS__New(Map),
40
+ currentRoomIndex = nil,
41
+ currentRoomVisitedCount = nil
42
+ }
43
+ }
44
+ function ____exports.getCollectibleItemPoolTypeInit(self, mod)
45
+ initialized = true
46
+ saveDataManager(nil, "getCollectibleItemPoolType", v)
47
+ mod:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, postPickupInitCollectible, PickupVariant.PICKUP_COLLECTIBLE)
48
+ mod:AddCallback(ModCallbacks.MC_PRE_GET_COLLECTIBLE, preGetCollectible)
49
+ end
50
+ function ____exports.getCollectibleItemPoolType(self, collectible)
51
+ if not initialized then
52
+ local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
53
+ error(msg)
54
+ end
55
+ if (collectible.Type ~= EntityType.ENTITY_PICKUP) or (collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE) then
56
+ error(
57
+ (((("The \"getCollectibleItemPoolType()\" function was given a non-collectible: " .. tostring(collectible.Type)) .. ".") .. tostring(collectible.Variant)) .. ".") .. tostring(collectible.SubType)
58
+ )
59
+ end
60
+ local ptrHash = GetPtrHash(collectible)
61
+ local itemPoolType = v.run.collectibleItemPoolTypeMap:get(ptrHash)
62
+ return ((itemPoolType == nil) and getRoomItemPoolType(nil)) or itemPoolType
63
+ end
64
+ return ____exports
@@ -62,7 +62,8 @@ import { SaveData } from "../../types/SaveData";
62
62
  *
63
63
  * @param key The name of the file or feature that is submitting data to be managed by the save data
64
64
  * manager. The save data manager will throw an error if the key is already registered.
65
- * @param saveData An object that corresponds to the `SaveData` interface.
65
+ * @param saveData An object that corresponds to the `SaveData` interface. The object is
66
+ * conventionally called "v" for brevity (which is short for "local variables").
66
67
  * @param conditionalFunc An optional function to run upon saving this key to disk. If the function
67
68
  * is false, the key will not be written to disk. This allows mod features to avoid cluttering the
68
69
  * "save#.dat" file with unnecessary keys.
@@ -1,9 +1,5 @@
1
1
  import { ModUpgraded } from "../../types/ModUpgraded";
2
- /** @hidden */
3
2
  export declare const FEATURE_NAME = "save data manager";
4
- /** @hidden */
5
3
  export declare function saveDataManagerInit(incomingMod: ModUpgraded): void;
6
- /** @hidden */
7
4
  export declare function isSaveDataManagerInitialized(): boolean;
8
- /** @hidden */
9
5
  export declare function forceSaveDataManagerSave(): void;
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./collectibleNameMap";
4
4
  export * from "./constants";
5
5
  export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
6
6
  export { forgottenSwitch } from "./features/forgottenSwitch";
7
+ export { getCollectibleItemPoolType } from "./features/getCollectibleItemPoolType";
7
8
  export { runInNFrames, runNextFrame } from "./features/runInNFrames";
8
9
  export * from "./features/saveDataManager/exports";
9
10
  export { hasSirenStolenFamiliar, setFamiliarNoSirenSteal, } from "./features/sirenHelpers";
package/dist/index.lua CHANGED
@@ -51,6 +51,11 @@ do
51
51
  local forgottenSwitch = ____forgottenSwitch.forgottenSwitch
52
52
  ____exports.forgottenSwitch = forgottenSwitch
53
53
  end
54
+ do
55
+ local ____getCollectibleItemPoolType = require("features.getCollectibleItemPoolType")
56
+ local getCollectibleItemPoolType = ____getCollectibleItemPoolType.getCollectibleItemPoolType
57
+ ____exports.getCollectibleItemPoolType = getCollectibleItemPoolType
58
+ end
54
59
  do
55
60
  local ____runInNFrames = require("features.runInNFrames")
56
61
  local runInNFrames = ____runInNFrames.runInNFrames
@@ -5,14 +5,14 @@ import { ModUpgraded } from "./types/ModUpgraded";
5
5
  *
6
6
  * Example:
7
7
  * ```
8
- * const mod = RegisterMod("My Mod", 1);
9
- * const modUpgraded = upgradeMod(mod);
8
+ * const modVanilla = RegisterMod("My Mod", 1);
9
+ * const mod = upgradeMod(modVanilla);
10
10
  *
11
11
  * // Subscribe to vanilla callbacks
12
12
  * mod.AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate);
13
13
  *
14
14
  * // Subscribe to custom callbacks
15
- * modUpgraded.AddCallbackCustom(ModCallbacksCustom.MC_POST_ITEM_PICKUP, postItemPickup);
15
+ * mod.AddCallbackCustom(ModCallbacksCustom.MC_POST_ITEM_PICKUP, postItemPickup);
16
16
  * ```
17
17
  *
18
18
  * For a list of all custom callbacks, check out the
@@ -60,6 +60,8 @@ local ____disableInputs = require("features.disableInputs")
60
60
  local disableInputsInit = ____disableInputs.disableInputsInit
61
61
  local ____forgottenSwitch = require("features.forgottenSwitch")
62
62
  local forgottenSwitchInit = ____forgottenSwitch.forgottenSwitchInit
63
+ local ____getCollectibleItemPoolType = require("features.getCollectibleItemPoolType")
64
+ local getCollectibleItemPoolTypeInit = ____getCollectibleItemPoolType.getCollectibleItemPoolTypeInit
63
65
  local ____runInNFrames = require("features.runInNFrames")
64
66
  local runInNFramesInit = ____runInNFrames.runInNFramesInit
65
67
  local ____main = require("features.saveDataManager.main")
@@ -100,6 +102,7 @@ end
100
102
  function initFeatures(self, mod)
101
103
  disableInputsInit(nil, mod)
102
104
  forgottenSwitchInit(nil, mod)
105
+ getCollectibleItemPoolTypeInit(nil, mod)
103
106
  runInNFramesInit(nil, mod)
104
107
  sirenHelpersInit(nil, mod)
105
108
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.459",
3
+ "version": "1.0.460",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",