cityrp.weighted_random

Weighted random table calculators.

Functions

weighted_random:Add(data, weight)

View source »

Add a new set of data, optionally with weight.

Parameters

  • data

    Any data. If a table, the .weight field is taken as the weight.

  • weight int optional

    A manual override weight value.

Returns

  • cityrp.weighted_random

weighted_random:New()

View source »

Create a new weighted random table instance.

Returns

  • cityrp.weighted_random

weighted_random:Random()

View source »

Pull out a random value from the table, respecting the weights of the table.

Returns

  • mixed

    Value from the table.