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:
35
scripts/nodes/library/lua/setMetatable.js
Normal file
35
scripts/nodes/library/lua/setMetatable.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Applies a metatable to a table via setmetatable().
|
||||
*/
|
||||
export const luaSetMetatableNode = createNodeModule(
|
||||
{
|
||||
id: "lua_setmetatable",
|
||||
title: "Set Metatable",
|
||||
category: "Lua",
|
||||
description: "Assign a metatable to a table using setmetatable().",
|
||||
searchTags: ["setmetatable", "metatable", "lua"],
|
||||
inputs: [
|
||||
{ id: "table", name: "Table", direction: "input", kind: "table" },
|
||||
{
|
||||
id: "metatable",
|
||||
name: "Metatable",
|
||||
direction: "input",
|
||||
kind: "table",
|
||||
defaultValue: "nil",
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "table_out", name: "Table", direction: "output", kind: "table" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
evaluateValue: ({ resolveValueInput }) => {
|
||||
const tableValue = resolveValueInput("table", "{}");
|
||||
const metatable = resolveValueInput("metatable", "nil");
|
||||
return `setmetatable(${tableValue}, ${metatable})`;
|
||||
},
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user