added reset_seed
This commit is contained in:
1 parent
ece43b6213
commit
eab24f7896
6 files changed
+21
-2
No files matched your search
@@ -313,6 +313,11 @@ public class Expression
|
||||
addUnaryFunction(name, (v) -> new NumericValue(fun.apply(NumericValue.asNumber(v).getDouble())));
|
||||
}
|
||||
|
||||
public void addMathematicalUnaryIntFunction(String name, Function<Double, Long> fun)
|
||||
{
|
||||
addUnaryFunction(name, (v) -> new NumericValue(fun.apply(NumericValue.asNumber(v).getDouble())));
|
||||
}
|
||||
|
||||
public void addMathematicalBinaryFunction(String name, BiFunction<Double, Double, Double> fun)
|
||||
{
|
||||
addBinaryFunction(name, (w, v) ->
|
||||
|
||||
@@ -42,6 +42,10 @@ public abstract class ScriptHost
|
||||
return randomizers.computeIfAbsent(aLong, Random::new);
|
||||
}
|
||||
|
||||
public boolean resetRandom(long aLong) {
|
||||
return randomizers.remove(aLong) != null;
|
||||
}
|
||||
|
||||
public static class ModuleData
|
||||
{
|
||||
Module parent;
|
||||
|
||||
@@ -210,6 +210,10 @@ public class Sys {
|
||||
Value retval = new NumericValue(NumericValue.asNumber(argument).getDouble()*randomizer.nextDouble());
|
||||
return (cc, tt) -> retval;
|
||||
});
|
||||
expression.addLazyFunction("reset_seed", 1, (c, t, lv) -> {
|
||||
boolean gotIt = c.host.resetRandom(NumericValue.asNumber(lv.get(0).evalValue(c)).getLong());
|
||||
return gotIt?LazyValue.TRUE:LazyValue.FALSE;
|
||||
});
|
||||
|
||||
expression.addLazyFunction("perlin", -1, (c, t, lv) ->
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user