Script misc_helpers

misc.

common tools for 4dguns

math helpers

weighted_randoms (tbl) picks a random index, with odds based on it's value.


math helpers

in guns4d.math
weighted_randoms (tbl)
picks a random index, with odds based on it's value. Returns the index of the selected.

Parameters:

  • tbl

    a table containing weights, example

      {
          ["sound"] = 999, --999 in 1000 chance this is chosen
          ["rare_sound"] = 1 --1 in 1000 chance this is chosen
      }
    
generated by LDoc 1.5.0 Last updated 2024-03-28 12:47:10