Confirmedusers
536
edits
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> | 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 | |||
== 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> | ||
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| | [[File:Txtpositiveclampedsinus.png|180px]] | ||
[[File:Txtcosinus.png| | [[File:Txtcosinus.png|180px]] | ||
[[File:Txtidentical.png| | [[File:Txtidentical.png|180px]] | ||
[[File:Txtinverselinear.png| | [[File:Txtinverselinear.png|180px]]<br><br> | ||
[[File:Txtlinear.png| | [[File:Txtlinear.png|180px]] | ||
[[File:Txtlinearincrease.png| | [[File:Txtlinearincrease.png|180px]] | ||
[[File:TxtlinearnullifyFirstValMinusFive.png| | [[File:TxtlinearnullifyFirstValMinusFive.png|180px]] | ||
[[File:Txtlinearreduce.png| | [[File:Txtlinearreduce.png|180px]]<br><br> | ||
[[File:Txtquadratic.png| | [[File:Txtquadratic.png|180px]] | ||
[[File:Txtroot.png| | [[File:Txtroot.png|180px]] | ||
[[File:Txtsinus.png| | [[File:Txtsinus.png|180px]] | ||
[[File:Txtsmoothstep.png| | [[File:Txtsmoothstep.png|180px]] | ||
{{Navbox/codemodding}} |