mirror of
https://github.com/litruv/picoGraph.git
synced 2026-07-24 02:36:04 +10:00
30 lines
894 B
JavaScript
30 lines
894 B
JavaScript
import { createNodeModule } from "../../nodeTypes.js";
|
|
|
|
/**
|
|
* Seeds the random number generator using srand.
|
|
*/
|
|
export const mathSrandNode = createNodeModule(
|
|
{
|
|
id: "math_srand",
|
|
title: "Seed Random",
|
|
category: "Math",
|
|
description: "Set the random number generator seed.",
|
|
searchTags: ["srand", "random", "seed", "math"],
|
|
inputs: [
|
|
{ id: "exec_in", name: "Exec", direction: "input", kind: "exec" },
|
|
{ id: "value", name: "Seed", direction: "input", kind: "number" },
|
|
],
|
|
outputs: [
|
|
{ id: "exec_out", name: "Exec", direction: "output", kind: "exec" },
|
|
],
|
|
properties: [],
|
|
},
|
|
{
|
|
emitExec: ({ indent, indentLevel, resolveValueInput, emitNextExec }) => {
|
|
const value = resolveValueInput("value", "0");
|
|
const line = `${indent(indentLevel)}srand(${value})`;
|
|
return [line, ...emitNextExec("exec_out")];
|
|
},
|
|
}
|
|
);
|