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 )⚓︎
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).
Example Code
1 2 3 4 5 |
|
AddOutcomeWeight ()⚓︎
void AddOutcomeWeight ( int Value, int Weight )⚓︎
Adds an outcome to the outcome selector with the specified Weight
.
Example Code
1 2 3 4 5 |
|
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.
Table structure & usage
- The returned table contains a list of outcomes, where each outcome is a table containing the following fields:
- Value: value of the outcome
- Weight: weight of the outcome
1 2 3
for i, outcome in ipairs(p:GetOutcomes()) do print(outcome.Value, outcome.Weight) end
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
.