Class "WeightedOutcomePicker"⚓︎
An example mod using the WeightedOutcomePicker class can be found here.
Info
This class can be obtained using its constructor:
Example Code
1 |
|
Constructors⚓︎
WeightedOutcomePicker ()⚓︎
WeightedOutcomePicker WeightedOutcomePicker ( )⚓︎
Functions⚓︎
AddOutcomeFloat ()⚓︎
void AddOutcomeFloat ( int Value, float Weight, int ScaleFactor = 100 )⚓︎
picker:AddOutcomeFloat(3, 0.2) -- ~9%
Adds an outcome to the outcome selector with the specified Weight
. The internal weight is still an integer calculated like this: fWeight * scaleFactor
, where ScaleFactor
is the maximum weight (equivalent to 1.0).
picker:AddOutcomeFloat(2, 1.0) -- ~45%
local picker = WeightedOutcomePicker()
1 |
|
AddOutcomeWeight ()⚓︎
void AddOutcomeWeight ( int Value, int Weight )⚓︎
picker:AddOutcomeWeight(3, 5) -- 5% picker:AddOutcomeWeight(1, 65) -- 65% local picker = WeightedOutcomePicker()
1 2 3 |
|
ClearOutcomes ()⚓︎
void ClearOutcomes ( )⚓︎
Clears all outcomes from the outcome picker.
GetNumOutcomes ()⚓︎
int GetNumOutcomes ( )⚓︎
Returns the number of outcomes in the outcome picker.
GetOutcomes ()⚓︎
table[] GetOutcomes ( )⚓︎
Returns a table containing a list of all outcomes in the outcome picker. print(outcome.Value, outcome.Weight) end
1 2 3 4 5 |
|
PickOutcome ()⚓︎
int PickOutcome ( RNG RNG )⚓︎
Returns a random outcome from the list in WeightedOutcomePicker. Accepts RNG.
RemoveOutcome ()⚓︎
void RemoveOutcome ( int Value )⚓︎
Removes an outcome from the outcome picker with the given Value
.