isaacscript-common 7.16.2 → 7.17.1

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.
@@ -8,6 +8,19 @@ export declare function disableInputsInit(mod: Mod): void;
8
8
  * that multiple mod features can work in tandem.
9
9
  */
10
10
  export declare function enableAllInputs(key: string): void;
11
+ /**
12
+ * Helper function to disable specific inputs, like opening the console.
13
+ *
14
+ * This function is variadic, meaning that you can pass as many inputs as you want to disable. (To
15
+ * disable all inputs, see the `disableAllInputs` function.
16
+ *
17
+ * Use the `enableAllInputs` helper function to set things back to normal.
18
+ *
19
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
20
+ * that multiple mod features can work in tandem.
21
+ * @param buttonActions An array of the actions to action.
22
+ */
23
+ export declare function disableInputs(key: string, ...buttonActions: ButtonAction[]): void;
11
24
  /**
12
25
  * Helper function to disable all inputs. This is useful because `EntityPlayer.ControlsEnabled` can
13
26
  * be changed by the game under certain conditions.
@@ -1 +1 @@
1
- {"version":3,"file":"disableInputs.d.ts","sourceRoot":"","sources":["../../src/features/disableInputs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,8BAA8B,CAAC;AAiBtC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAoBhD;AA+CD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAKjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAKlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,GACvD,IAAI,CAKN;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,GACvD,IAAI,CAKN;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGvD"}
1
+ {"version":3,"file":"disableInputs.d.ts","sourceRoot":"","sources":["../../src/features/disableInputs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,8BAA8B,CAAC;AA0BtC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAoBhD;AAqDD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAKjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,GAAG,aAAa,EAAE,YAAY,EAAE,GAC/B,IAAI,CAKN;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAKlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,GACvD,IAAI,CAKN;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,GACvD,IAAI,CAKN;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGvD"}
@@ -32,12 +32,17 @@ function getReturnValue(self, buttonAction, booleanCallback)
32
32
  ____booleanCallback_0 = 0
33
33
  end
34
34
  local disableValue = ____booleanCallback_0
35
- for ____, whitelist in __TS__Iterator(v.run.disableInputsWithWhitelistMap:values()) do
35
+ for ____, blacklist in __TS__Iterator(v.run.disableInputs:values()) do
36
+ if blacklist:has(buttonAction) then
37
+ return disableValue
38
+ end
39
+ end
40
+ for ____, whitelist in __TS__Iterator(v.run.disableAllInputsWithWhitelistMap:values()) do
36
41
  if not whitelist:has(buttonAction) then
37
42
  return disableValue
38
43
  end
39
44
  end
40
- for ____, blacklist in __TS__Iterator(v.run.enableInputsWithBlacklistMap:values()) do
45
+ for ____, blacklist in __TS__Iterator(v.run.enableAllInputsWithBlacklistMap:values()) do
41
46
  if blacklist:has(buttonAction) then
42
47
  return disableValue
43
48
  end
@@ -46,8 +51,9 @@ function getReturnValue(self, buttonAction, booleanCallback)
46
51
  end
47
52
  local FEATURE_NAME = "disableInputs"
48
53
  v = {run = {
49
- disableInputsWithWhitelistMap = __TS__New(Map),
50
- enableInputsWithBlacklistMap = __TS__New(Map)
54
+ disableInputs = __TS__New(Map),
55
+ enableAllInputsWithBlacklistMap = __TS__New(Map),
56
+ disableAllInputsWithWhitelistMap = __TS__New(Map)
51
57
  }}
52
58
  function ____exports.disableInputsInit(self, mod)
53
59
  saveDataManager(nil, FEATURE_NAME, v)
@@ -62,8 +68,24 @@ end
62
68
  -- that multiple mod features can work in tandem.
63
69
  function ____exports.enableAllInputs(self, key)
64
70
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
65
- v.run.disableInputsWithWhitelistMap:delete(key)
66
- v.run.enableInputsWithBlacklistMap:delete(key)
71
+ v.run.disableAllInputsWithWhitelistMap:delete(key)
72
+ v.run.enableAllInputsWithBlacklistMap:delete(key)
73
+ end
74
+ --- Helper function to disable specific inputs, like opening the console.
75
+ --
76
+ -- This function is variadic, meaning that you can pass as many inputs as you want to disable. (To
77
+ -- disable all inputs, see the `disableAllInputs` function.
78
+ --
79
+ -- Use the `enableAllInputs` helper function to set things back to normal.
80
+ --
81
+ -- @param key The name of the mod feature that is requesting the enable/disable. This is needed so
82
+ -- that multiple mod features can work in tandem.
83
+ -- @param buttonActions An array of the actions to action.
84
+ function ____exports.disableInputs(self, key, ...)
85
+ local buttonActions = {...}
86
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
87
+ local buttonActionsSet = __TS__New(Set, buttonActions)
88
+ v.run.disableInputs:set(key, buttonActionsSet)
67
89
  end
68
90
  --- Helper function to disable all inputs. This is useful because `EntityPlayer.ControlsEnabled` can
69
91
  -- be changed by the game under certain conditions.
@@ -74,11 +96,11 @@ end
74
96
  -- that multiple mod features can work in tandem.
75
97
  function ____exports.disableAllInputs(self, key)
76
98
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
77
- v.run.disableInputsWithWhitelistMap:set(
99
+ v.run.disableAllInputsWithWhitelistMap:set(
78
100
  key,
79
101
  __TS__New(Set)
80
102
  )
81
- v.run.enableInputsWithBlacklistMap:delete(key)
103
+ v.run.enableAllInputsWithBlacklistMap:delete(key)
82
104
  end
83
105
  --- Helper function to enable all inputs besides the ones provided. This is useful because
84
106
  -- `EntityPlayer.ControlsEnabled` can be changed by the game under certain conditions.
@@ -90,8 +112,8 @@ end
90
112
  -- @param blacklist A set of ButtonActions to disallow.
91
113
  function ____exports.enableAllInputsExceptFor(self, key, blacklist)
92
114
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
93
- v.run.disableInputsWithWhitelistMap:delete(key)
94
- v.run.enableInputsWithBlacklistMap:set(key, blacklist)
115
+ v.run.disableAllInputsWithWhitelistMap:delete(key)
116
+ v.run.enableAllInputsWithBlacklistMap:set(key, blacklist)
95
117
  end
96
118
  --- Helper function to disable all inputs besides the ones provided. This is useful because
97
119
  -- `EntityPlayer.ControlsEnabled` can be changed by the game under certain conditions.
@@ -103,8 +125,8 @@ end
103
125
  -- @param whitelist A set of ButtonActions to allow.
104
126
  function ____exports.disableAllInputsExceptFor(self, key, whitelist)
105
127
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
106
- v.run.disableInputsWithWhitelistMap:set(key, whitelist)
107
- v.run.enableInputsWithBlacklistMap:delete(key)
128
+ v.run.disableAllInputsWithWhitelistMap:set(key, whitelist)
129
+ v.run.enableAllInputsWithBlacklistMap:delete(key)
108
130
  end
109
131
  --- Helper function to disable only the inputs used for moving the character (or moving the cursor in
110
132
  -- the UI). This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under
@@ -1 +1 @@
1
- {"version":3,"file":"pause.d.ts","sourceRoot":"","sources":["../../src/features/pause.ts"],"names":[],"mappings":";AAuCA,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAUxC;AA2DD;;;;;;;GAOG;AACH,wBAAgB,KAAK,IAAI,IAAI,CA8C5B;AAED,wFAAwF;AACxF,wBAAgB,OAAO,IAAI,IAAI,CAqB9B"}
1
+ {"version":3,"file":"pause.d.ts","sourceRoot":"","sources":["../../src/features/pause.ts"],"names":[],"mappings":";AAuCA,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAUxC;AA2DD;;;;;;;GAOG;AACH,wBAAgB,KAAK,IAAI,IAAI,CA8C5B;AAED,wFAAwF;AACxF,wBAAgB,OAAO,IAAI,IAAI,CAsB9B"}
@@ -19,12 +19,12 @@ function hexToRGB(self, hexString)
19
19
  if r == nil then
20
20
  error(("Failed to convert `0x" .. rString) .. "` to a number.")
21
21
  end
22
- local gString = __TS__StringSubstring(hexString, 2, 2)
22
+ local gString = __TS__StringSubstring(hexString, 2, 4)
23
23
  local g = tonumber("0x" .. gString)
24
24
  if g == nil then
25
25
  error(("Failed to convert `0x" .. gString) .. "` to a number.")
26
26
  end
27
- local bString = __TS__StringSubstring(hexString, 4, 2)
27
+ local bString = __TS__StringSubstring(hexString, 4, 6)
28
28
  local b = tonumber("0x" .. bString)
29
29
  if b == nil then
30
30
  error(("Failed to convert `0x" .. bString) .. "` to a number.")
@@ -1207,6 +1207,16 @@ local function __TS__InstanceOfObject(value)
1207
1207
  return valueType == "table" or valueType == "function"
1208
1208
  end
1209
1209
 
1210
+ local function __TS__LuaIteratorSpread(self, state, firstKey)
1211
+ local results = {}
1212
+ local key, value = self(state, firstKey)
1213
+ while key do
1214
+ results[#results + 1] = {key, value}
1215
+ key, value = self(state, key)
1216
+ end
1217
+ return __TS__Unpack(results)
1218
+ end
1219
+
1210
1220
  local Map
1211
1221
  do
1212
1222
  Map = __TS__Class()
@@ -2448,6 +2458,7 @@ return {
2448
2458
  __TS__InstanceOf = __TS__InstanceOf,
2449
2459
  __TS__InstanceOfObject = __TS__InstanceOfObject,
2450
2460
  __TS__Iterator = __TS__Iterator,
2461
+ __TS__LuaIteratorSpread = __TS__LuaIteratorSpread,
2451
2462
  Map = Map,
2452
2463
  __TS__MathAtan2 = __TS__MathAtan2,
2453
2464
  __TS__MathSign = __TS__MathSign,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "7.16.2",
3
+ "version": "7.17.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -12,10 +12,19 @@ const FEATURE_NAME = "disableInputs";
12
12
  const v = {
13
13
  run: {
14
14
  /** Indexed by the requesting feature key. */
15
- disableInputsWithWhitelistMap: new Map<string, ReadonlySet<ButtonAction>>(),
15
+ disableInputs: new Map<string, ReadonlySet<ButtonAction>>(),
16
16
 
17
17
  /** Indexed by the requesting feature key. */
18
- enableInputsWithBlacklistMap: new Map<string, ReadonlySet<ButtonAction>>(),
18
+ enableAllInputsWithBlacklistMap: new Map<
19
+ string,
20
+ ReadonlySet<ButtonAction>
21
+ >(),
22
+
23
+ /** Indexed by the requesting feature key. */
24
+ disableAllInputsWithWhitelistMap: new Map<
25
+ string,
26
+ ReadonlySet<ButtonAction>
27
+ >(),
19
28
  },
20
29
  };
21
30
 
@@ -71,13 +80,19 @@ function getActionValue(
71
80
  function getReturnValue(buttonAction: ButtonAction, booleanCallback: boolean) {
72
81
  const disableValue = booleanCallback ? false : 0;
73
82
 
74
- for (const whitelist of v.run.disableInputsWithWhitelistMap.values()) {
83
+ for (const blacklist of v.run.disableInputs.values()) {
84
+ if (blacklist.has(buttonAction)) {
85
+ return disableValue;
86
+ }
87
+ }
88
+
89
+ for (const whitelist of v.run.disableAllInputsWithWhitelistMap.values()) {
75
90
  if (!whitelist.has(buttonAction)) {
76
91
  return disableValue;
77
92
  }
78
93
  }
79
94
 
80
- for (const blacklist of v.run.enableInputsWithBlacklistMap.values()) {
95
+ for (const blacklist of v.run.enableAllInputsWithBlacklistMap.values()) {
81
96
  if (blacklist.has(buttonAction)) {
82
97
  return disableValue;
83
98
  }
@@ -96,8 +111,30 @@ function getReturnValue(buttonAction: ButtonAction, booleanCallback: boolean) {
96
111
  export function enableAllInputs(key: string): void {
97
112
  errorIfFeaturesNotInitialized(FEATURE_NAME);
98
113
 
99
- v.run.disableInputsWithWhitelistMap.delete(key);
100
- v.run.enableInputsWithBlacklistMap.delete(key);
114
+ v.run.disableAllInputsWithWhitelistMap.delete(key);
115
+ v.run.enableAllInputsWithBlacklistMap.delete(key);
116
+ }
117
+
118
+ /**
119
+ * Helper function to disable specific inputs, like opening the console.
120
+ *
121
+ * This function is variadic, meaning that you can pass as many inputs as you want to disable. (To
122
+ * disable all inputs, see the `disableAllInputs` function.
123
+ *
124
+ * Use the `enableAllInputs` helper function to set things back to normal.
125
+ *
126
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
127
+ * that multiple mod features can work in tandem.
128
+ * @param buttonActions An array of the actions to action.
129
+ */
130
+ export function disableInputs(
131
+ key: string,
132
+ ...buttonActions: ButtonAction[]
133
+ ): void {
134
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
135
+
136
+ const buttonActionsSet = new Set(buttonActions);
137
+ v.run.disableInputs.set(key, buttonActionsSet);
101
138
  }
102
139
 
103
140
  /**
@@ -112,8 +149,8 @@ export function enableAllInputs(key: string): void {
112
149
  export function disableAllInputs(key: string): void {
113
150
  errorIfFeaturesNotInitialized(FEATURE_NAME);
114
151
 
115
- v.run.disableInputsWithWhitelistMap.set(key, new Set());
116
- v.run.enableInputsWithBlacklistMap.delete(key);
152
+ v.run.disableAllInputsWithWhitelistMap.set(key, new Set());
153
+ v.run.enableAllInputsWithBlacklistMap.delete(key);
117
154
  }
118
155
 
119
156
  /**
@@ -132,8 +169,8 @@ export function enableAllInputsExceptFor(
132
169
  ): void {
133
170
  errorIfFeaturesNotInitialized(FEATURE_NAME);
134
171
 
135
- v.run.disableInputsWithWhitelistMap.delete(key);
136
- v.run.enableInputsWithBlacklistMap.set(key, blacklist);
172
+ v.run.disableAllInputsWithWhitelistMap.delete(key);
173
+ v.run.enableAllInputsWithBlacklistMap.set(key, blacklist);
137
174
  }
138
175
 
139
176
  /**
@@ -152,8 +189,8 @@ export function disableAllInputsExceptFor(
152
189
  ): void {
153
190
  errorIfFeaturesNotInitialized(FEATURE_NAME);
154
191
 
155
- v.run.disableInputsWithWhitelistMap.set(key, whitelist);
156
- v.run.enableInputsWithBlacklistMap.delete(key);
192
+ v.run.disableAllInputsWithWhitelistMap.set(key, whitelist);
193
+ v.run.enableAllInputsWithBlacklistMap.delete(key);
157
194
  }
158
195
 
159
196
  /**
@@ -181,7 +181,8 @@ export function unpause(): void {
181
181
  // After a vanilla pause, the tears will not resume their normal velocity and will "stick" to the
182
182
  // air. Even if we try to help the tears along by explicitly resetting all of the velocity-related
183
183
  // variables to their initial values, this will not make a difference. Thus, revert to removing
184
- // all of the tears and projectiles in the room.
184
+ // all of the tears and projectiles in the room. (If a Ludovico tear is removed, it will
185
+ // automatically be respawned on the next frame.)
185
186
  removeAllTears();
186
187
  removeAllProjectiles();
187
188
  }
@@ -82,13 +82,13 @@ function hexToRGB(hexString: string): [r: float, g: float, b: float] {
82
82
  error(`Failed to convert \`0x${rString}\` to a number.`);
83
83
  }
84
84
 
85
- const gString = hexString.substring(2, 2);
85
+ const gString = hexString.substring(2, 4);
86
86
  const g = tonumber(`0x${gString}`);
87
87
  if (g === undefined) {
88
88
  error(`Failed to convert \`0x${gString}\` to a number.`);
89
89
  }
90
90
 
91
- const bString = hexString.substring(4, 2);
91
+ const bString = hexString.substring(4, 6);
92
92
  const b = tonumber(`0x${bString}`);
93
93
  if (b === undefined) {
94
94
  error(`Failed to convert \`0x${bString}\` to a number.`);