mirror of
https://github.com/litruv/picoGraph.git
synced 2026-07-24 02:36:04 +10:00
Initial commit
moved from private version control
This commit is contained in:
52
scripts/nodes/library/graphics/fset.js
Normal file
52
scripts/nodes/library/graphics/fset.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Updates sprite flag values.
|
||||
*/
|
||||
export const fsetNode = createNodeModule(
|
||||
{
|
||||
id: "graphics_fset",
|
||||
title: "Set Sprite Flag",
|
||||
category: "Graphics",
|
||||
description: "Set a sprite's flag bitfield or a specific flag value.",
|
||||
searchTags: ["fset", "flag", "sprite", "meta"],
|
||||
inputs: [
|
||||
{ id: "exec_in", name: "Exec", direction: "input", kind: "exec" },
|
||||
{
|
||||
id: "sprite",
|
||||
name: "Sprite",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{ id: "flag", name: "Flag", direction: "input", kind: "number" },
|
||||
{
|
||||
id: "value",
|
||||
name: "Value",
|
||||
direction: "input",
|
||||
kind: "any",
|
||||
defaultValue: true,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "exec_out", name: "Exec", direction: "output", kind: "exec" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
emitExec: ({ indent, indentLevel, resolveValueInput, emitNextExec }) => {
|
||||
const OMIT = "__pg_omit__";
|
||||
const sprite = resolveValueInput("sprite", "0");
|
||||
const flag = resolveValueInput("flag", OMIT);
|
||||
const value = resolveValueInput("value", "false");
|
||||
const args = [sprite];
|
||||
if (flag === OMIT) {
|
||||
args.push(value);
|
||||
} else {
|
||||
args.push(flag, value);
|
||||
}
|
||||
const line = `${indent(indentLevel)}fset(${args.join(", ")})`;
|
||||
return [line, ...emitNextExec("exec_out")];
|
||||
},
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user