Files
picoGraph/scripts/core/lua/LuaLiteralBoolean.js
Max Litruv Boonzaayer f917cf6ad5 Add initial Pico-8 cartridges for testing
- Created test_cart.p8 with basic drawing functionality and a print statement.
- Created test_unix.p8 with a simple initialization function.
2026-03-21 18:38:43 +11:00

42 lines
1.0 KiB
JavaScript

/**
* @typedef {import('./LuaLiteralTypes.js').LuaLiteralHandler} LuaLiteralHandler
*/
/** @type {LuaLiteralHandler} */
export const LuaLiteralBoolean = {
/**
* @param {unknown} value
* @returns {string}
*/
format(value) {
if (typeof value === "string") {
return value === "false" ? "false" : "true";
}
return value ? "true" : "false";
},
/** @returns {string} */
defaultLiteral() {
return "false";
},
spawnableByDefault: true,
nodeModule: {
definition: {
id: "boolean_literal",
title: "Boolean",
category: "Values",
description: "Constant boolean literal.",
searchTags: ["boolean", "literal", "true", "false"],
inputs: [],
outputs: [{ id: "value", name: "Value", direction: "output", kind: "boolean" }],
properties: [{ key: "value", label: "Value", type: "boolean", defaultValue: true }],
},
behavior: {
evaluateValue: ({ node, formatLiteral }) =>
formatLiteral("boolean", node.properties.value ?? true),
},
},
};