@quenty/randomutils 6.2.0 → 6.2.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.2.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/randomutils@6.2.0...@quenty/randomutils@6.2.1) (2024-04-28)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * RandomUtils.weightedChoice when chances array starts with 0(s) ([cd4a616](https://github.com/Quenty/NevermoreEngine/commit/cd4a61663ece9f731f1c6184ae0107124f1120dd))
12
+
13
+
14
+
15
+
16
+
6
17
  # [6.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/randomutils@6.1.0...@quenty/randomutils@6.2.0) (2024-04-27)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/randomutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/randomutils",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "description": "Quenty's RandomUtils, utility functions for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -32,5 +32,5 @@
32
32
  "@quenty/loader": "^10.2.0",
33
33
  "@quenty/table": "^3.4.0"
34
34
  },
35
- "gitHead": "5c9eab1eac73f0d54953cca5017b7be968182f72"
35
+ "gitHead": "70324645c6d74b1e46612e88c318c0f7564c32d8"
36
36
  }
@@ -145,6 +145,9 @@ function RandomUtils.weightedChoice(list, weights, random)
145
145
  local totalSum = 0
146
146
 
147
147
  for i=1, #list do
148
+ if weights[i] == 0 then
149
+ continue
150
+ end
148
151
  totalSum = totalSum + weights[i]
149
152
  local threshold = totalSum/total
150
153
  if randomNum <= threshold then
@@ -188,4 +191,4 @@ function RandomUtils.randomUnitVector3(random)
188
191
  RandomUtils.gaussianRandom(random))
189
192
  end
190
193
 
191
- return RandomUtils
194
+ return RandomUtils