isaacscript-common 1.0.355 → 1.0.359

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.
@@ -39,4 +39,5 @@ export declare const MAX_PLAYER_TRINKET_SLOTS = 2;
39
39
  */
40
40
  export declare const MAX_ROOM_INDEX = 168;
41
41
  export declare const MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_DECAP_ATTACK;
42
+ export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
42
43
  export declare const SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES: Set<CollectibleType>;
@@ -18,5 +18,6 @@ ____exports.MAX_PLAYER_SPEED_IN_UNITS = 9.8
18
18
  ____exports.MAX_PLAYER_TRINKET_SLOTS = 2
19
19
  ____exports.MAX_ROOM_INDEX = 168
20
20
  ____exports.MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_DECAP_ATTACK
21
+ ____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
21
22
  ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {CollectibleType.COLLECTIBLE_FORGET_ME_NOW, CollectibleType.COLLECTIBLE_EDENS_SOUL, CollectibleType.COLLECTIBLE_ALABASTER_BOX, CollectibleType.COLLECTIBLE_PLAN_C, CollectibleType.COLLECTIBLE_MAMA_MEGA, CollectibleType.COLLECTIBLE_SACRIFICIAL_ALTAR, CollectibleType.COLLECTIBLE_DEATH_CERTIFICATE, CollectibleType.COLLECTIBLE_R_KEY})
22
23
  return ____exports
@@ -8,8 +8,16 @@ export declare function arrayInArray<T>(arrayToMatch: T[], parentArray: T[][]):
8
8
  export declare function arrayToString<T>(array: T[]): string;
9
9
  export declare function getRandomArrayElement<T>(array: T[], seed: int): T;
10
10
  export declare function getRandomArrayIndex<T>(array: T[], seed: int): int;
11
- /** Copies and removes the specified element from the array. Returns the copied array. */
11
+ /**
12
+ * Shallow copies and removes the specified element from the array. Returns the copied array. If the
13
+ * specified element is not found in the array, it will simply return a shallow copy of the array.
14
+ */
12
15
  export declare function arrayRemove<T>(array: T[], element: T): T[];
16
+ /**
17
+ * Removes the specified element from the array. If the specified element is not found in the array,
18
+ * this function will do nothing. Returns whether or not the element was found.
19
+ */
20
+ export declare function arrayRemoveInPlace<T>(array: T[], element: T): boolean;
13
21
  /**
14
22
  * Initializes an array with all elements containing the specified default value.
15
23
  *
@@ -65,6 +65,14 @@ function ____exports.arrayRemove(self, array, element)
65
65
  __TS__ArraySplice(arrayCopy, index, 1)
66
66
  return arrayCopy
67
67
  end
68
+ function ____exports.arrayRemoveInPlace(self, array, element)
69
+ local index = __TS__ArrayIndexOf(array, element)
70
+ if index == -1 then
71
+ return false
72
+ end
73
+ __TS__ArraySplice(array, index, 1)
74
+ return true
75
+ end
68
76
  function ____exports.initArray(self, defaultValue, size)
69
77
  local array = {}
70
78
  do
@@ -21,3 +21,6 @@
21
21
  */
22
22
  export declare function getGridEntities(...gridEntityTypes: GridEntityType[]): GridEntity[];
23
23
  export declare function getSurroundingGridEntities(gridEntity: GridEntity): GridEntity[];
24
+ export declare function spawnGiantPoop(topLeftGridIndex: int): void;
25
+ export declare function spawnGridEntity(gridEntityType: GridEntityType, gridIndex: int): GridEntity;
26
+ export declare function spawnGridEntityWithVariant(gridEntityType: GridEntityType, variant: int, gridIndex: int): GridEntity;
@@ -1,6 +1,12 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
+ function ____exports.spawnGridEntityWithVariant(self, gridEntityType, variant, gridIndex)
5
+ local game = Game()
6
+ local room = game:GetRoom()
7
+ local position = room:GetGridPosition(gridIndex)
8
+ return Isaac.GridSpawn(gridEntityType, variant, position, true)
9
+ end
4
10
  function ____exports.getGridEntities(self, ...)
5
11
  local gridEntityTypes = {...}
6
12
  local game = Game()
@@ -46,4 +52,19 @@ function ____exports.getSurroundingGridEntities(self, gridEntity)
46
52
  end
47
53
  return surroundingGridEntities
48
54
  end
55
+ function ____exports.spawnGiantPoop(self, topLeftGridIndex)
56
+ local game = Game()
57
+ local room = game:GetRoom()
58
+ local gridWidth = room:GetGridWidth()
59
+ local topRightGridIndex = topLeftGridIndex + 1
60
+ local bottomLeftGridIndex = topLeftGridIndex + gridWidth
61
+ local bottomRightGridIndex = bottomLeftGridIndex + 1
62
+ ____exports.spawnGridEntityWithVariant(nil, GridEntityType.GRID_POOP, 7, topLeftGridIndex)
63
+ ____exports.spawnGridEntityWithVariant(nil, GridEntityType.GRID_POOP, 8, topRightGridIndex)
64
+ ____exports.spawnGridEntityWithVariant(nil, GridEntityType.GRID_POOP, 9, bottomLeftGridIndex)
65
+ ____exports.spawnGridEntityWithVariant(nil, GridEntityType.GRID_POOP, 10, bottomRightGridIndex)
66
+ end
67
+ function ____exports.spawnGridEntity(self, gridEntityType, gridIndex)
68
+ return ____exports.spawnGridEntityWithVariant(nil, gridEntityType, 0, gridIndex)
69
+ end
49
70
  return ____exports
@@ -22,3 +22,6 @@ export declare function temporarilyRemoveTrinkets(player: EntityPlayer, trinketT
22
22
  * removed.
23
23
  */
24
24
  export declare function giveTrinketsBack(player: EntityPlayer, trinketSituation: TrinketSituation | undefined): void;
25
+ export declare function getMaxTrinketID(): int;
26
+ /** Returns a set containing every valid trinket type in the game, including modded items. */
27
+ export declare function getTrinketSet(): Set<TrinketType | int>;
@@ -1,7 +1,10 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
2
3
  local ____exports = {}
3
4
  local ____constants = require("constants")
4
5
  local GOLDEN_TRINKET_SHIFT = ____constants.GOLDEN_TRINKET_SHIFT
6
+ local ____util = require("functions.util")
7
+ local copySet = ____util.copySet
5
8
  function ____exports.temporarilyRemoveTrinkets(self, player, trinketType)
6
9
  if not player:HasTrinket(trinketType) then
7
10
  return nil
@@ -51,4 +54,28 @@ function ____exports.giveTrinketsBack(self, player, trinketSituation)
51
54
  player:AddTrinket(trinketSituation.trinket2, false)
52
55
  end
53
56
  end
57
+ function ____exports.getMaxTrinketID(self)
58
+ local itemConfig = Isaac.GetItemConfig()
59
+ return itemConfig:GetTrinkets().Size - 1
60
+ end
61
+ local TRINKET_SET = __TS__New(Set)
62
+ local function initSet(self)
63
+ local itemConfig = Isaac.GetItemConfig()
64
+ do
65
+ local trinketType = 1
66
+ while trinketType <= ____exports.getMaxTrinketID(nil) do
67
+ local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
68
+ if itemConfigTrinket ~= nil then
69
+ TRINKET_SET:add(trinketType)
70
+ end
71
+ trinketType = trinketType + 1
72
+ end
73
+ end
74
+ end
75
+ function ____exports.getTrinketSet(self)
76
+ if TRINKET_SET.size == 0 then
77
+ initSet(nil)
78
+ end
79
+ return copySet(nil, TRINKET_SET)
80
+ end
54
81
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.355",
3
+ "version": "1.0.359",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,10 +25,10 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.243",
28
+ "isaac-typescript-definitions": "^1.0.246",
29
29
  "isaacscript-lint": "^1.0.63",
30
30
  "typedoc": "^0.22.7",
31
31
  "typescript": "4.4.4",
32
- "typescript-to-lua": "^1.1.0"
32
+ "typescript-to-lua": "^1.1.1"
33
33
  }
34
34
  }