EvolvingNatFloat: Difference between revisions

From Vintage Story Wiki
m
Changed example code for readability.
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><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 Example
public class EvolvingNatFloatMod : ModSystem
{
    Example()
     {
     {
        float factor = 1;


         EvolvingNatFloat evolve;
         public override void StartServerSide(ICoreServerAPI api)
        evolve = new EvolvingNatFloat(
        {
            EnumTransformFunction.CLAMPEDPOSITIVESINUS,
            float factor = 1;
            factor
 
            EvolvingNatFloat evolve;
            evolve = new EvolvingNatFloat(
                EnumTransformFunction.CLAMPEDPOSITIVESINUS,
                factor


        );
            );


        float firstValue = 5;
            float firstValue = 5;
        for (float sequence = firstValue; sequence < 100; sequence++)
            for (float sequence = firstValue; sequence < 100; sequence++)
        {
            {
            // Retrieve each sequential value
                // Retrieve each sequential value
            float y = evolve.nextFloat(firstValue, sequence);
                float y = evolve.nextFloat(firstValue, sequence);
            }
         }
         }
     }
     }
}
</syntaxhighlight>
</syntaxhighlight>


Confirmedusers
536

edits