isaacscript-common 1.2.83 → 1.2.84

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.
@@ -0,0 +1,6 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * When used on The Forgotten, switches to The Soul. When used on The Soul, switches to The
4
+ * Forgotten. This takes 1 game frame to take effect.
5
+ */
6
+ export declare function isPonyActive(player: EntityPlayer): boolean;
@@ -0,0 +1,50 @@
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 postPEffectUpdate, FLAGS_WHEN_PONY_IS_ACTIVE, v
7
+ local ____errors = require("errors")
8
+ local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
9
+ local ____flag = require("functions.flag")
10
+ local hasFlag = ____flag.hasFlag
11
+ local ____player = require("functions.player")
12
+ local getPlayerIndex = ____player.getPlayerIndex
13
+ local ____exports = require("features.saveDataManager.exports")
14
+ local saveDataManager = ____exports.saveDataManager
15
+ function postPEffectUpdate(self, player)
16
+ local effects = player:GetEffects()
17
+ local entityFlags = player:GetEntityFlags()
18
+ local hasPonyCollectibleEffect = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_PONY) or effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_WHITE_PONY)
19
+ local playerIndex = getPlayerIndex(nil, player)
20
+ local isPonyActiveOnPreviousFrame = v.run.playersIsPonyActive:has(playerIndex)
21
+ local hasPonyFlags = hasFlag(
22
+ nil,
23
+ entityFlags,
24
+ table.unpack(FLAGS_WHEN_PONY_IS_ACTIVE)
25
+ )
26
+ local isPonyActiveNow = hasPonyCollectibleEffect or isPonyActiveOnPreviousFrame and hasPonyFlags
27
+ if isPonyActiveNow then
28
+ v.run.playersIsPonyActive:add(playerIndex)
29
+ else
30
+ v.run.playersIsPonyActive:delete(playerIndex)
31
+ end
32
+ end
33
+ local FEATURE_NAME = "pony activation detector"
34
+ FLAGS_WHEN_PONY_IS_ACTIVE = {EntityFlag.FLAG_NO_KNOCKBACK, EntityFlag.FLAG_NO_PHYSICS_KNOCKBACK, EntityFlag.FLAG_NO_DAMAGE_BLINK}
35
+ local initialized = false
36
+ v = {run = {playersIsPonyActive = __TS__New(Set)}}
37
+ function ____exports.isPonyActiveInit(self, mod)
38
+ initialized = true
39
+ saveDataManager(nil, "isPonyActive", v)
40
+ mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, postPEffectUpdate)
41
+ end
42
+ function ____exports.isPonyActive(self, player)
43
+ if not initialized then
44
+ local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
45
+ error(msg)
46
+ end
47
+ local playerIndex = getPlayerIndex(nil, player)
48
+ return v.run.playersIsPonyActive:has(playerIndex)
49
+ end
50
+ return ____exports
@@ -43,13 +43,11 @@ function ____exports.logAllFlags(flags, flagEnum, description)
43
43
  end
44
44
  ____exports.log(("Logging all " .. description) .. "flags:")
45
45
  local hasNoFlags = true
46
- local i = 1
47
46
  for key, value in pairs(flagEnum) do
48
47
  if hasFlag(nil, flags, value) then
49
- ____exports.log((((((" " .. tostring(i)) .. ") Has flag: ") .. tostring(key)) .. " (") .. tostring(value)) .. ")")
48
+ ____exports.log((((" Has flag: " .. tostring(key)) .. " (") .. tostring(value)) .. ")")
50
49
  hasNoFlags = false
51
50
  end
52
- i = i + 1
53
51
  end
54
52
  if hasNoFlags then
55
53
  ____exports.log(" n/a (no flags)")
@@ -65,15 +63,13 @@ function ____exports.logAllGameStateFlags()
65
63
  local game = Game()
66
64
  ____exports.log("Logging all game state flags:")
67
65
  local hasNoFlags = true
68
- local i = 1
69
66
  for key, value in pairs(GameStateFlag) do
70
67
  local gameStateFlag = value
71
68
  local flagValue = game:GetStateFlag(gameStateFlag)
72
69
  if flagValue then
73
- ____exports.log((((((" " .. tostring(i)) .. ") Has flag: ") .. key) .. " (") .. tostring(value)) .. ")")
70
+ ____exports.log((((" Has flag: " .. key) .. " (") .. tostring(value)) .. ")")
74
71
  hasNoFlags = false
75
72
  end
76
- i = i + 1
77
73
  end
78
74
  if hasNoFlags then
79
75
  ____exports.log(" n/a (no flags)")
@@ -87,14 +83,12 @@ function ____exports.logAllSeedEffects()
87
83
  local seeds = game:GetSeeds()
88
84
  ____exports.log("Logging all seed effects:")
89
85
  local hasNoSeedEffects = true
90
- local i = 1
91
86
  for key, value in pairs(SeedEffect) do
92
87
  local seedEffect = value
93
88
  if seeds:HasSeedEffect(seedEffect) then
94
- ____exports.log((((((" " .. tostring(i)) .. ") ") .. key) .. " (") .. tostring(value)) .. ")")
89
+ ____exports.log((((" " .. key) .. " (") .. tostring(value)) .. ")")
95
90
  hasNoSeedEffects = false
96
91
  end
97
- i = i + 1
98
92
  end
99
93
  if hasNoSeedEffects then
100
94
  ____exports.log(" n/a (no seed effects)")
@@ -1,18 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { HealthType } from "../types/HealthType";
3
- /**
4
- * PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
5
- * function. Mods can signify that data structures handle EntityPlayers by using this type:
6
- *
7
- * ```
8
- * const myPlayerMap = new Map<PlayerIndex, string>();
9
- * ```
10
- *
11
- * This type is branded for extra type safety.
12
- */
13
- export declare type PlayerIndex = int & {
14
- __playerIndexBrand: unknown;
15
- };
3
+ import { PlayerIndex } from "../types/PlayerIndex";
16
4
  export declare function addCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType | int): void;
17
5
  export declare function addTrinketCostume(player: EntityPlayer, trinketType: TrinketType | int): void;
18
6
  /** Iterates over all players and checks if any player is close enough to the specified position. */
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { deployJSONRoom, deployRandomJSONRoom, emptyRoom, } from "./features/dep
4
4
  export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
5
5
  export { forgottenSwitch } from "./features/forgottenSwitch";
6
6
  export { getCollectibleItemPoolType } from "./features/getCollectibleItemPoolType";
7
+ export { isPonyActive } from "./features/isPonyActive";
7
8
  export { preventCollectibleRotate } from "./features/preventCollectibleRotate";
8
9
  export { runInNGameFrames, runInNRenderFrames, runNextGameFrame, runNextRenderFrame, } from "./features/runInNFrames";
9
10
  export * from "./features/saveDataManager/exports";
@@ -92,6 +93,7 @@ export * from "./types/PickingUpItem";
92
93
  export * from "./types/PillEffectClass";
93
94
  export * from "./types/PillEffectType";
94
95
  export * from "./types/PlayerHealth";
96
+ export * from "./types/PlayerIndex";
95
97
  export * from "./types/PocketItemDescription";
96
98
  export * from "./types/PocketItemType";
97
99
  export * from "./types/TrinketSituation";
package/dist/index.lua CHANGED
@@ -49,6 +49,11 @@ do
49
49
  local getCollectibleItemPoolType = ____getCollectibleItemPoolType.getCollectibleItemPoolType
50
50
  ____exports.getCollectibleItemPoolType = getCollectibleItemPoolType
51
51
  end
52
+ do
53
+ local ____isPonyActive = require("features.isPonyActive")
54
+ local isPonyActive = ____isPonyActive.isPonyActive
55
+ ____exports.isPonyActive = isPonyActive
56
+ end
52
57
  do
53
58
  local ____preventCollectibleRotate = require("features.preventCollectibleRotate")
54
59
  local preventCollectibleRotate = ____preventCollectibleRotate.preventCollectibleRotate
@@ -0,0 +1,14 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
4
+ * function. Mods can signify that data structures handle EntityPlayers by using this type:
5
+ *
6
+ * ```
7
+ * const myPlayerMap = new Map<PlayerIndex, string>();
8
+ * ```
9
+ *
10
+ * This type is branded for extra type safety.
11
+ */
12
+ export declare type PlayerIndex = int & {
13
+ __playerIndexBrand: unknown;
14
+ };
@@ -0,0 +1,3 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.83",
3
+ "version": "1.2.84",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",