mirror of
https://github.com/litruv/picoGraph.git
synced 2026-07-24 10:46:06 +10:00
Initial commit
moved from private version control
This commit is contained in:
33
scripts/nodes/library/data/cartdata.js
Normal file
33
scripts/nodes/library/data/cartdata.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Opens persistent cartridge storage using cartdata.
|
||||
*/
|
||||
export const cartdataNode = createNodeModule(
|
||||
{
|
||||
id: "data_cartdata",
|
||||
title: "Cart Data Init",
|
||||
category: "Data",
|
||||
description: "Setup persistent storage for the cartridge using CARTDATA().",
|
||||
searchTags: ["cartdata", "save", "persistent", "data"],
|
||||
inputs: [
|
||||
{
|
||||
id: "id",
|
||||
name: "Identifier",
|
||||
direction: "input",
|
||||
kind: "string",
|
||||
defaultValue: "\"my_cart\"",
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "loaded", name: "Loaded", direction: "output", kind: "boolean" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
evaluateValue: ({ resolveValueInput }) => {
|
||||
const id = resolveValueInput("id", '"pico_cart"');
|
||||
return `cartdata(${id})`;
|
||||
},
|
||||
}
|
||||
);
|
||||
33
scripts/nodes/library/data/dget.js
Normal file
33
scripts/nodes/library/data/dget.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Reads a persistent value using dget.
|
||||
*/
|
||||
export const dgetNode = createNodeModule(
|
||||
{
|
||||
id: "data_dget",
|
||||
title: "Data Get",
|
||||
category: "Data",
|
||||
description: "Retrieve a persistent number using DGET().",
|
||||
searchTags: ["dget", "load", "data", "persistent"],
|
||||
inputs: [
|
||||
{
|
||||
id: "index",
|
||||
name: "Index",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "value", name: "Value", direction: "output", kind: "number" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
evaluateValue: ({ resolveValueInput }) => {
|
||||
const index = resolveValueInput("index", "0");
|
||||
return `dget(${index})`;
|
||||
},
|
||||
}
|
||||
);
|
||||
43
scripts/nodes/library/data/dset.js
Normal file
43
scripts/nodes/library/data/dset.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Writes a persistent value using dset.
|
||||
*/
|
||||
export const dsetNode = createNodeModule(
|
||||
{
|
||||
id: "data_dset",
|
||||
title: "Data Set",
|
||||
category: "Data",
|
||||
description: "Store a persistent number using DSET().",
|
||||
searchTags: ["dset", "save", "data", "persistent"],
|
||||
inputs: [
|
||||
{ id: "exec_in", name: "Exec", direction: "input", kind: "exec" },
|
||||
{
|
||||
id: "index",
|
||||
name: "Index",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
id: "value",
|
||||
name: "Value",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "exec_out", name: "Exec", direction: "output", kind: "exec" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
emitExec: ({ indent, indentLevel, resolveValueInput, emitNextExec }) => {
|
||||
const index = resolveValueInput("index", "0");
|
||||
const value = resolveValueInput("value", "0");
|
||||
const line = `${indent(indentLevel)}dset(${index}, ${value})`;
|
||||
return [line, ...emitNextExec("exec_out")];
|
||||
},
|
||||
}
|
||||
);
|
||||
18
scripts/nodes/library/data/index.js
Normal file
18
scripts/nodes/library/data/index.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { cartdataNode } from "./cartdata.js";
|
||||
import { dsetNode } from "./dset.js";
|
||||
import { dgetNode } from "./dget.js";
|
||||
|
||||
/**
|
||||
* All data persistence node modules backed by PICO-8 helpers.
|
||||
*/
|
||||
export const dataNodes = [cartdataNode, dsetNode, dgetNode];
|
||||
|
||||
/**
|
||||
* Checklist tracking coverage of documented cart data helpers.
|
||||
* @type {Array<{ function: string, nodeId: string, implemented: boolean }>}
|
||||
*/
|
||||
export const dataFunctionChecklist = [
|
||||
{ function: "CARTDATA", nodeId: "data_cartdata", implemented: true },
|
||||
{ function: "DSET", nodeId: "data_dset", implemented: true },
|
||||
{ function: "DGET", nodeId: "data_dget", implemented: true },
|
||||
];
|
||||
Reference in New Issue
Block a user