Confirmedusers
536
edits
m (Added version number.) |
m (Changed example code for readability.) |
||
Line 5: | Line 5: | ||
Each sequential value is retrieved according to the first value and the sequence number. | Each sequential value is retrieved according to the first value and the sequence number. | ||
To use EvolvingNatFloat, add the using statement for '''Vintagestory.API.MathTools'''.<br> | To use EvolvingNatFloat, add the using statement for '''Vintagestory.API.MathTools'''.<br>'''''Important note''': The value of sequence should always satisfy '''sequence >= 0''''' | ||
'''''Important note''': The value of sequence should always satisfy '''sequence >= 0''''' | |||
== Example in code == | == Example in code == | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
using Vintagestory.API.MathTools; | using Vintagestory.API.MathTools; | ||
class | public class EvolvingNatFloatMod : ModSystem | ||
{ | { | ||
EvolvingNatFloat evolve; | public override void StartServerSide(ICoreServerAPI api) | ||
{ | |||
float factor = 1; | |||
EvolvingNatFloat evolve; | |||
evolve = new EvolvingNatFloat( | |||
EnumTransformFunction.CLAMPEDPOSITIVESINUS, | |||
factor | |||
); | |||
float firstValue = 5; | |||
for (float sequence = firstValue; sequence < 100; sequence++) | |||
{ | |||
// Retrieve each sequential value | |||
float y = evolve.nextFloat(firstValue, sequence); | |||
} | |||
} | } | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||