isaacscript-common 1.2.6 → 1.2.7

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.
@@ -104,10 +104,12 @@ export declare const MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B;
104
104
  export declare const MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING;
105
105
  export declare const SECOND_IN_MILLISECONDS = 1000;
106
106
  export declare const MINUTE_IN_MILLISECONDS: number;
107
- export declare const MOVEMENT_ACTIONS: Set<ButtonAction>;
107
+ export declare const MOVEMENT_ACTIONS: ButtonAction[];
108
+ export declare const MOVEMENT_ACTIONS_SET: Set<ButtonAction>;
108
109
  export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
109
110
  export declare const SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES: Set<CollectibleType>;
110
- export declare const SHOOTING_ACTIONS: Set<ButtonAction>;
111
+ export declare const SHOOTING_ACTIONS: ButtonAction[];
112
+ export declare const SHOOTING_ACTIONS_SET: Set<ButtonAction>;
111
113
  export declare const STORY_BOSSES: Set<EntityType>;
112
114
  /**
113
115
  * This is the number of draw coordinates that each heart spans on the UI in the upper left hand
@@ -90,7 +90,8 @@ ____exports.MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B
90
90
  ____exports.MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING
91
91
  ____exports.SECOND_IN_MILLISECONDS = 1000
92
92
  ____exports.MINUTE_IN_MILLISECONDS = 60 * ____exports.SECOND_IN_MILLISECONDS
93
- ____exports.MOVEMENT_ACTIONS = __TS__New(Set, {ButtonAction.ACTION_LEFT, ButtonAction.ACTION_RIGHT, ButtonAction.ACTION_UP, ButtonAction.ACTION_DOWN})
93
+ ____exports.MOVEMENT_ACTIONS = {ButtonAction.ACTION_LEFT, ButtonAction.ACTION_RIGHT, ButtonAction.ACTION_UP, ButtonAction.ACTION_DOWN}
94
+ ____exports.MOVEMENT_ACTIONS_SET = __TS__New(Set, ____exports.MOVEMENT_ACTIONS)
94
95
  ____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
95
96
  ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
96
97
  CollectibleType.COLLECTIBLE_FORGET_ME_NOW,
@@ -102,7 +103,8 @@ ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
102
103
  CollectibleType.COLLECTIBLE_DEATH_CERTIFICATE,
103
104
  CollectibleType.COLLECTIBLE_R_KEY
104
105
  })
105
- ____exports.SHOOTING_ACTIONS = __TS__New(Set, {ButtonAction.ACTION_SHOOTLEFT, ButtonAction.ACTION_SHOOTRIGHT, ButtonAction.ACTION_SHOOTUP, ButtonAction.ACTION_SHOOTDOWN})
106
+ ____exports.SHOOTING_ACTIONS = {ButtonAction.ACTION_SHOOTLEFT, ButtonAction.ACTION_SHOOTRIGHT, ButtonAction.ACTION_SHOOTUP, ButtonAction.ACTION_SHOOTDOWN}
107
+ ____exports.SHOOTING_ACTIONS_SET = __TS__New(Set, ____exports.SHOOTING_ACTIONS)
106
108
  ____exports.STORY_BOSSES = __TS__New(Set, {
107
109
  EntityType.ENTITY_MOM,
108
110
  EntityType.ENTITY_MOMS_HEART,
@@ -4,8 +4,8 @@ local Set = ____lualib.Set
4
4
  local ____exports = {}
5
5
  local isActionPressed, isActionTriggered, getActionValue, getReturnValue, v
6
6
  local ____constants = require("constants")
7
- local MOVEMENT_ACTIONS = ____constants.MOVEMENT_ACTIONS
8
- local SHOOTING_ACTIONS = ____constants.SHOOTING_ACTIONS
7
+ local MOVEMENT_ACTIONS_SET = ____constants.MOVEMENT_ACTIONS_SET
8
+ local SHOOTING_ACTIONS_SET = ____constants.SHOOTING_ACTIONS_SET
9
9
  local ____errors = require("errors")
10
10
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
11
11
  local ____exports = require("features.saveDataManager.exports")
@@ -85,9 +85,9 @@ function ____exports.disableAllInputsExceptFor(self, whitelist)
85
85
  v.run.blacklist = nil
86
86
  end
87
87
  function ____exports.disableMovementInputs(self)
88
- ____exports.enableAllInputsExceptFor(nil, MOVEMENT_ACTIONS)
88
+ ____exports.enableAllInputsExceptFor(nil, MOVEMENT_ACTIONS_SET)
89
89
  end
90
90
  function ____exports.disableShootingInputs(self)
91
- ____exports.enableAllInputsExceptFor(nil, SHOOTING_ACTIONS)
91
+ ____exports.enableAllInputsExceptFor(nil, SHOOTING_ACTIONS_SET)
92
92
  end
93
93
  return ____exports
@@ -1,15 +1,16 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
- local Set = ____lualib.Set
4
3
  local __TS__StringReplace = ____lualib.__TS__StringReplace
5
4
  local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
6
- local __TS__Iterator = ____lualib.__TS__Iterator
5
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
7
6
  local __TS__StringSlice = ____lualib.__TS__StringSlice
8
7
  local ____exports = {}
9
8
  local ____constants = require("constants")
10
9
  local MAX_NUM_INPUTS = ____constants.MAX_NUM_INPUTS
11
10
  local MOVEMENT_ACTIONS = ____constants.MOVEMENT_ACTIONS
12
11
  local SHOOTING_ACTIONS = ____constants.SHOOTING_ACTIONS
12
+ local ____math = require("functions.math")
13
+ local range = ____math.range
13
14
  local ControllerLiteral = ControllerLiteral or ({})
14
15
  ControllerLiteral.DPAD_LEFT = 0
15
16
  ControllerLiteral[ControllerLiteral.DPAD_LEFT] = "DPAD_LEFT"
@@ -72,63 +73,45 @@ function ____exports.controllerToString(self, controller)
72
73
  return "unknown"
73
74
  end
74
75
  function ____exports.isActionPressedOnAnyInput(self, buttonAction)
75
- do
76
- local i = 0
77
- while i < MAX_NUM_INPUTS do
78
- if Input.IsActionPressed(buttonAction, i) then
79
- return true
80
- end
81
- i = i + 1
82
- end
83
- end
84
- return false
76
+ local validInputs = range(nil, 0, MAX_NUM_INPUTS - 1)
77
+ return __TS__ArraySome(
78
+ validInputs,
79
+ function(____, input) return Input.IsActionPressed(buttonAction, input) end
80
+ )
85
81
  end
86
82
  function ____exports.isActionTriggeredOnAnyInput(self, buttonAction)
87
- do
88
- local i = 0
89
- while i < MAX_NUM_INPUTS do
90
- if Input.IsActionTriggered(buttonAction, i) then
91
- return true
92
- end
93
- i = i + 1
94
- end
95
- end
96
- return false
83
+ local validInputs = range(nil, 0, MAX_NUM_INPUTS - 1)
84
+ return __TS__ArraySome(
85
+ validInputs,
86
+ function(____, input) return Input.IsActionTriggered(buttonAction, input) end
87
+ )
97
88
  end
98
89
  function ____exports.isKeyboardPressed(self, key)
99
90
  return Input.IsButtonPressed(key, 0)
100
91
  end
101
92
  function ____exports.isMoveActionPressedOnAnyInput(self)
102
- for ____, buttonAction in __TS__Iterator(MOVEMENT_ACTIONS:values()) do
103
- if ____exports.isActionPressedOnAnyInput(nil, buttonAction) then
104
- return true
105
- end
106
- end
107
- return false
93
+ return __TS__ArraySome(
94
+ MOVEMENT_ACTIONS,
95
+ function(____, moveAction) return ____exports.isActionPressedOnAnyInput(nil, moveAction) end
96
+ )
108
97
  end
109
98
  function ____exports.isMoveActionTriggeredOnAnyInput(self)
110
- for ____, buttonAction in __TS__Iterator(MOVEMENT_ACTIONS:values()) do
111
- if ____exports.isActionTriggeredOnAnyInput(nil, buttonAction) then
112
- return true
113
- end
114
- end
115
- return false
99
+ return __TS__ArraySome(
100
+ MOVEMENT_ACTIONS,
101
+ function(____, moveAction) return ____exports.isActionTriggeredOnAnyInput(nil, moveAction) end
102
+ )
116
103
  end
117
104
  function ____exports.isShootActionPressedOnAnyInput(self)
118
- for ____, buttonAction in __TS__Iterator(SHOOTING_ACTIONS:values()) do
119
- if ____exports.isActionPressedOnAnyInput(nil, buttonAction) then
120
- return true
121
- end
122
- end
123
- return false
105
+ return __TS__ArraySome(
106
+ SHOOTING_ACTIONS,
107
+ function(____, shootAction) return ____exports.isActionPressedOnAnyInput(nil, shootAction) end
108
+ )
124
109
  end
125
110
  function ____exports.isShootActionTriggeredOnAnyInput(self)
126
- for ____, buttonAction in __TS__Iterator(SHOOTING_ACTIONS:values()) do
127
- if ____exports.isActionTriggeredOnAnyInput(nil, buttonAction) then
128
- return true
129
- end
130
- end
131
- return false
111
+ return __TS__ArraySome(
112
+ SHOOTING_ACTIONS,
113
+ function(____, shootAction) return ____exports.isActionTriggeredOnAnyInput(nil, shootAction) end
114
+ )
132
115
  end
133
116
  function ____exports.keyboardToString(self, keyboard)
134
117
  for ____, ____value in ipairs(__TS__ObjectEntries(Keyboard)) do
@@ -17,6 +17,8 @@ export declare function isEven(num: int): boolean;
17
17
  export declare function isOdd(num: int): boolean;
18
18
  export declare function lerp(a: number, b: number, pos: float): number;
19
19
  export declare function lerpAngleDegrees(aStart: number, aEnd: number, percent: float): number;
20
+ /** Helper function to return an array with the elements from start to end, inclusive. */
21
+ export declare function range(start: int, end: int): int[];
20
22
  /**
21
23
  * If rounding fails, this function returns 0.
22
24
  * From: http://lua-users.org/wiki/SimpleRound
@@ -87,6 +87,17 @@ end
87
87
  function ____exports.lerpAngleDegrees(self, aStart, aEnd, percent)
88
88
  return aStart + ____exports.getAngleDifference(nil, aStart, aEnd) * percent
89
89
  end
90
+ function ____exports.range(self, start, ____end)
91
+ local array = {}
92
+ do
93
+ local i = start
94
+ while i <= ____end do
95
+ __TS__ArrayPush(array, i)
96
+ i = i + 1
97
+ end
98
+ end
99
+ return array
100
+ end
90
101
  function ____exports.round(self, num, numDecimalPlaces)
91
102
  if numDecimalPlaces == nil then
92
103
  numDecimalPlaces = 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.0",
29
- "isaac-typescript-definitions": "^1.0.334",
29
+ "isaac-typescript-definitions": "^1.0.335",
30
30
  "isaacscript-lint": "^1.0.79",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.11",