127 lines
2.8 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>4dguns documentation</title>
<link rel="stylesheet" href="../ldoc_new.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>4dguns</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#math_helpers">math helpers </a></li>
</ul>
<h2>Scripts</h2>
<ul class="nowrap">
<li><a href="../scripts/item_entities.lua.html">item_entities.lua</a></li>
<li><strong>misc_helpers</strong></li>
<li><a href="../scripts/play_sound.html">play_sound</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/classes.player_model_handler.html">classes.player_model_handler</a></li>
<li><a href="../modules/default_controls.html">default_controls</a></li>
</ul>
<h2>Classes</h2>
<ul class="nowrap">
<li><a href="../classes/Gun.html">Gun</a></li>
<li><a href="../classes/Instantiatable_class.html">Instantiatable_class</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/readme.md.html">readme</a></li>
</ul>
</div>
<div id="content">
<h1>Script <code>misc_helpers</code></h1>
<p>misc.</p>
<p> common tools for 4dguns</p>
<h2><a href="#math_helpers">math helpers </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#weighted_randoms">weighted_randoms (tbl)</a></td>
<td class="summary">picks a random index, with odds based on it's value.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header has-description"><a name="math_helpers"></a>math helpers </h2>
<div class="section-description">
in guns4d.math
</div>
<dl class="function">
<dt>
<a name = "weighted_randoms"></a>
<strong>weighted_randoms (tbl)</strong>
</dt>
<dd>
picks a random index, with odds based on it's value. Returns the index of the selected.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">tbl</span>
<p> a table containing weights, example</p>
<pre><code> {
["sound"] = 999, --999 in 1000 chance this is chosen
["rare_sound"] = 1 --1 in 1000 chance this is chosen
}
</code></pre>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
<i style="float:right;">Last updated 2024-06-18 17:20:58 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>