Fix RandomNumberGenerator::rand_weighted return type

This commit is contained in:
David Luevano Alvarado
2024-03-02 15:34:51 -06:00
parent f2045ba822
commit 981883d041
4 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -24,13 +24,13 @@
Returns a random index with non-uniform weights. Prints an error and returns [code]-1[/code] if the array is empty.
[codeblocks]
[gdscript]
var rnd = RandomNumberGenerator.new()
var rng = RandomNumberGenerator.new()
var my_array = ["one", "two", "three, "four"]
var my_array = ["one", "two", "three", "four"]
var weights = PackedFloat32Array([0.5, 1, 1, 2])
# Prints one of the four elements in `my_array`.
# It is more likely to print "four", and less likely to print "two".
# It is more likely to print "four", and less likely to print "one".
print(my_array[rng.rand_weighted(weights)])
[/gdscript]
[/codeblocks]