Number addition in Lua - avoiding negative values
<p>This is not hardcore math but I simply cannot find the correct function to make this in a smooth way.</p>

<p>Lets say I have 3 values. Cost1 Cost2 Cost3. Each have a value, I want to add them together into a final number, TotalCost.</p>

<pre><code>Cost1+Cost2+Cost3 = TotalCost

Problem is, if any of Cost1/2/3 is negative, I want to make that a ZERO, ie;

Cost1 = -100
Cost2 = 50
Cost3 = 150

Cost1+Cost2+Cost3 = TotalCost 
equals
0 + 50 + 150 = 200
</code></pre>

<p>I know I have seen something with like (X*Math.Floor * 100) / 100 , to do just this, if im not completly mistaken.</p>

<p>Would be greatly apreciated if anyone could answer. I know its a basic question but I simply couldent figure out how (with a smart way that is) with the Math. functions.</p>

<p>Im coding in Lua: <a href="http://lua-users.org/wiki/MathLibraryTutorial" rel="nofollow">http://lua-users.org/wiki/MathLibraryTutorial</a></p>