EvolvingNatFloat: Difference between revisions

From Vintage Story Wiki
m
Updated navbox to new code navbox.
m (Edited photos, added warning about sequence limit, specified variables in functions.)
m (Updated navbox to new code navbox.)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{GameVersion|1.19.3}}
= EvolvingNatFloat =
= EvolvingNatFloat =
A number generator whose return value changes over time according to a transform and factor.<br>
A number generator whose return value changes over time according to a transform and factor.<br>
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>


Line 88: Line 89:
For every representation except smoothstep, linearnullify, the '''initalValue = 1'''<br>
For every representation except smoothstep, linearnullify, the '''initalValue = 1'''<br>


[[File:Txtpositiveclampedsinus.png|150px]]
[[File:Txtpositiveclampedsinus.png|180px]]
[[File:Txtcosinus.png|150px]]
[[File:Txtcosinus.png|180px]]
[[File:Txtidentical.png|150px]]
[[File:Txtidentical.png|180px]]
[[File:Txtinverselinear.png|150px]]<br><br>
[[File:Txtinverselinear.png|180px]]<br><br>
[[File:Txtlinear.png|150px]]
[[File:Txtlinear.png|180px]]
[[File:Txtlinearincrease.png|150px]]
[[File:Txtlinearincrease.png|180px]]
[[File:TxtlinearnullifyFirstValMinusFive.png|150px]]
[[File:TxtlinearnullifyFirstValMinusFive.png|180px]]
[[File:Txtlinearreduce.png|150px]]<br><br>
[[File:Txtlinearreduce.png|180px]]<br><br>
[[File:Txtquadratic.png|150px]]
[[File:Txtquadratic.png|180px]]
[[File:Txtroot.png|150px]]
[[File:Txtroot.png|180px]]
[[File:Txtsinus.png|150px]]
[[File:Txtsinus.png|180px]]
[[File:Txtsmoothstep.png|150px]]
[[File:Txtsmoothstep.png|180px]]
 
{{Navbox/codemodding}}
Confirmedusers
536

edits