2016-09-23 00:34:42 +02:00
|
|
|
import os
|
2021-01-17 00:23:02 +01:00
|
|
|
from typing import Optional, TextIO
|
|
|
|
|
2017-04-02 23:26:27 +02:00
|
|
|
import bpy
|
2021-01-17 00:23:19 +01:00
|
|
|
|
2017-11-09 19:47:10 +01:00
|
|
|
from arm.exporter import ArmoryExporter
|
2021-01-17 00:23:19 +01:00
|
|
|
import arm.log
|
2021-06-28 12:07:57 +02:00
|
|
|
import arm.node_utils
|
2021-01-17 00:23:19 +01:00
|
|
|
import arm.utils
|
2016-09-23 00:34:42 +02:00
|
|
|
|
2021-08-11 14:32:21 +02:00
|
|
|
if arm.is_reload(__name__):
|
2021-08-04 22:49:38 +02:00
|
|
|
arm.exporter = arm.reload_module(arm.exporter)
|
|
|
|
from arm.exporter import ArmoryExporter
|
|
|
|
arm.log = arm.reload_module(arm.log)
|
|
|
|
arm.node_utils = arm.reload_module(arm.node_utils)
|
|
|
|
arm.utils = arm.reload_module(arm.utils)
|
|
|
|
else:
|
2021-08-11 14:32:21 +02:00
|
|
|
arm.enable_reload(__name__)
|
2021-08-04 22:49:38 +02:00
|
|
|
|
2017-04-02 23:26:27 +02:00
|
|
|
parsed_nodes = []
|
2018-06-15 00:30:40 +02:00
|
|
|
parsed_ids = dict() # Sharing node data
|
2018-11-04 05:05:52 +01:00
|
|
|
function_nodes = dict()
|
|
|
|
function_node_outputs = dict()
|
2018-06-12 16:58:34 +02:00
|
|
|
group_name = ''
|
2017-04-02 23:26:27 +02:00
|
|
|
|
2021-06-28 12:07:57 +02:00
|
|
|
|
|
|
|
def get_logic_trees() -> list['arm.nodes_logic.ArmLogicTree']:
|
2018-03-01 16:15:13 +01:00
|
|
|
ar = []
|
|
|
|
for node_group in bpy.data.node_groups:
|
|
|
|
if node_group.bl_idname == 'ArmLogicTreeType':
|
2021-06-28 12:07:57 +02:00
|
|
|
node_group.use_fake_user = True # Keep fake references for now
|
2018-03-01 16:15:13 +01:00
|
|
|
ar.append(node_group)
|
|
|
|
return ar
|
|
|
|
|
2021-06-28 12:07:57 +02:00
|
|
|
|
2016-09-23 00:34:42 +02:00
|
|
|
# Generating node sources
|
2017-11-22 21:17:36 +01:00
|
|
|
def build():
|
2017-04-02 23:26:27 +02:00
|
|
|
os.chdir(arm.utils.get_fp())
|
2018-03-01 16:15:13 +01:00
|
|
|
trees = get_logic_trees()
|
|
|
|
if len(trees) > 0:
|
|
|
|
# Make sure package dir exists
|
|
|
|
nodes_path = 'Sources/' + arm.utils.safestr(bpy.data.worlds['Arm'].arm_project_package).replace(".", "/") + "/node"
|
|
|
|
if not os.path.exists(nodes_path):
|
|
|
|
os.makedirs(nodes_path)
|
|
|
|
# Export node scripts
|
|
|
|
for tree in trees:
|
|
|
|
build_node_tree(tree)
|
2016-09-23 00:34:42 +02:00
|
|
|
|
2021-06-28 12:07:57 +02:00
|
|
|
def build_node_tree(node_group: 'arm.nodes_logic.ArmLogicTree'):
|
2017-04-02 23:26:27 +02:00
|
|
|
global parsed_nodes
|
2018-06-15 00:30:40 +02:00
|
|
|
global parsed_ids
|
2018-11-04 05:05:52 +01:00
|
|
|
global function_nodes
|
|
|
|
global function_node_outputs
|
2018-06-12 16:58:34 +02:00
|
|
|
global group_name
|
2017-04-02 23:26:27 +02:00
|
|
|
parsed_nodes = []
|
2018-06-15 00:30:40 +02:00
|
|
|
parsed_ids = dict()
|
2018-11-04 05:05:52 +01:00
|
|
|
function_nodes = dict()
|
|
|
|
function_node_outputs = dict()
|
2017-04-02 23:26:27 +02:00
|
|
|
root_nodes = get_root_nodes(node_group)
|
|
|
|
|
2017-05-13 17:17:43 +02:00
|
|
|
pack_path = arm.utils.safestr(bpy.data.worlds['Arm'].arm_project_package)
|
|
|
|
path = 'Sources/' + pack_path.replace('.', '/') + '/node/'
|
2020-02-12 13:51:31 +01:00
|
|
|
|
2021-06-28 12:07:57 +02:00
|
|
|
group_name = arm.node_utils.get_export_tree_name(node_group, do_warn=True)
|
2017-05-25 16:48:41 +02:00
|
|
|
file = path + group_name + '.hx'
|
2016-09-23 00:34:42 +02:00
|
|
|
|
2018-01-29 12:17:14 +01:00
|
|
|
# Import referenced node group
|
|
|
|
for node in node_group.nodes:
|
|
|
|
if node.bl_idname == 'LNCallGroupNode':
|
|
|
|
prop = getattr(node, 'property0')
|
|
|
|
ArmoryExporter.import_traits.append(prop)
|
|
|
|
|
2018-12-19 20:10:34 +01:00
|
|
|
if node_group.arm_cached and os.path.isfile(file):
|
2017-05-25 16:48:41 +02:00
|
|
|
return
|
|
|
|
|
2021-06-28 12:07:57 +02:00
|
|
|
wrd = bpy.data.worlds['Arm']
|
|
|
|
|
2020-10-18 17:50:35 +02:00
|
|
|
with open(file, 'w', encoding="utf-8") as f:
|
2017-05-13 17:17:43 +02:00
|
|
|
f.write('package ' + pack_path + '.node;\n\n')
|
2021-07-24 13:36:16 +02:00
|
|
|
f.write('@:access(armory.logicnode.LogicNode)')
|
2017-04-04 23:11:31 +02:00
|
|
|
f.write('@:keep class ' + group_name + ' extends armory.logicnode.LogicTree {\n\n')
|
2018-11-04 05:05:52 +01:00
|
|
|
f.write('\tvar functionNodes:Map<String, armory.logicnode.FunctionNode>;\n\n')
|
|
|
|
f.write('\tvar functionOutputNodes:Map<String, armory.logicnode.FunctionOutputNode>;\n\n')
|
|
|
|
f.write('\tpublic function new() {\n')
|
|
|
|
f.write('\t\tsuper();\n')
|
2021-06-28 12:07:57 +02:00
|
|
|
if wrd.arm_debug_console:
|
2018-11-04 05:05:52 +01:00
|
|
|
f.write('\t\tname = "' + group_name + '";\n')
|
|
|
|
f.write('\t\tthis.functionNodes = new Map();\n')
|
|
|
|
f.write('\t\tthis.functionOutputNodes = new Map();\n')
|
2021-07-25 20:13:47 +02:00
|
|
|
if arm.utils.is_livepatch_enabled():
|
2021-07-26 00:02:54 +02:00
|
|
|
# Store a reference to this trait instance in Logictree.nodeTrees
|
|
|
|
f.write('\t\tvar nodeTrees = armory.logicnode.LogicTree.nodeTrees;\n')
|
|
|
|
f.write(f'\t\tif (nodeTrees.exists("{group_name}")) ' + '{\n')
|
|
|
|
f.write(f'\t\t\tnodeTrees["{group_name}"].push(this);\n')
|
|
|
|
f.write('\t\t} else {\n')
|
|
|
|
f.write(f'\t\t\tnodeTrees["{group_name}"] = cast [this];\n')
|
|
|
|
f.write('\t\t}\n')
|
|
|
|
f.write('\t\tnotifyOnRemove(() -> { nodeTrees.remove("' + group_name + '"); });\n')
|
2018-11-04 05:05:52 +01:00
|
|
|
f.write('\t\tnotifyOnAdd(add);\n')
|
|
|
|
f.write('\t}\n\n')
|
2018-01-29 13:52:39 +01:00
|
|
|
f.write('\toverride public function add() {\n')
|
2017-04-02 23:26:27 +02:00
|
|
|
for node in root_nodes:
|
2017-05-06 00:22:15 +02:00
|
|
|
build_node(node, f)
|
2016-09-28 00:00:59 +02:00
|
|
|
f.write('\t}\n')
|
2020-02-12 13:51:31 +01:00
|
|
|
|
2018-11-04 05:05:52 +01:00
|
|
|
# Create node functions
|
|
|
|
for node_name in function_nodes:
|
|
|
|
node = function_nodes[node_name]
|
|
|
|
function_name = node.function_name
|
|
|
|
f.write('\n\tpublic function ' + function_name + '(')
|
|
|
|
for i in range(0, len(node.outputs) - 1):
|
|
|
|
if i != 0: f.write(', ')
|
|
|
|
f.write('arg' + str(i) + ':Dynamic')
|
|
|
|
f.write(') {\n')
|
|
|
|
f.write('\t\tvar functionNode = this.functionNodes["' + node_name + '"];\n')
|
|
|
|
f.write('\t\tfunctionNode.args = [];\n')
|
|
|
|
for i in range(0, len(node.outputs) - 1):
|
|
|
|
f.write('\t\tfunctionNode.args.push(arg' + str(i) + ');\n')
|
|
|
|
f.write('\t\tfunctionNode.run(0);\n')
|
|
|
|
if function_node_outputs.get(function_name) != None:
|
|
|
|
f.write('\t\treturn this.functionOutputNodes["' + function_node_outputs[function_name] + '"].result;\n')
|
|
|
|
f.write('\t}\n\n')
|
|
|
|
f.write('}')
|
2018-12-19 20:10:34 +01:00
|
|
|
node_group.arm_cached = True
|
2016-09-23 00:34:42 +02:00
|
|
|
|
2021-01-17 00:23:19 +01:00
|
|
|
|
|
|
|
def build_node(node: bpy.types.Node, f: TextIO) -> Optional[str]:
|
|
|
|
"""Builds the given node and returns its name. f is an opened file object."""
|
2017-04-02 23:26:27 +02:00
|
|
|
global parsed_nodes
|
2018-06-15 00:30:40 +02:00
|
|
|
global parsed_ids
|
2017-04-02 23:26:27 +02:00
|
|
|
|
2021-07-25 20:13:47 +02:00
|
|
|
use_live_patch = arm.utils.is_livepatch_enabled()
|
|
|
|
|
2017-04-04 23:11:31 +02:00
|
|
|
if node.type == 'REROUTE':
|
2018-04-16 00:24:44 +02:00
|
|
|
if len(node.inputs) > 0 and len(node.inputs[0].links) > 0:
|
|
|
|
return build_node(node.inputs[0].links[0].from_node, f)
|
|
|
|
else:
|
|
|
|
return None
|
2017-04-04 23:11:31 +02:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
# Get node name
|
2021-06-28 12:07:57 +02:00
|
|
|
name = arm.node_utils.get_export_node_name(node)
|
2016-09-23 00:34:42 +02:00
|
|
|
|
2018-06-15 00:30:40 +02:00
|
|
|
# Link nodes using IDs
|
|
|
|
if node.arm_logic_id != '':
|
|
|
|
if node.arm_logic_id in parsed_ids:
|
|
|
|
return parsed_ids[node.arm_logic_id]
|
|
|
|
parsed_ids[node.arm_logic_id] = name
|
2017-04-14 20:38:50 +02:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
# Check if node already exists
|
2017-04-02 23:26:27 +02:00
|
|
|
if name in parsed_nodes:
|
|
|
|
return name
|
2016-09-23 00:34:42 +02:00
|
|
|
|
2017-04-14 20:38:50 +02:00
|
|
|
parsed_nodes.append(name)
|
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
# Create node
|
2021-01-17 00:23:19 +01:00
|
|
|
node_type = node.bl_idname[2:] # Discard 'LN' prefix
|
2017-07-02 20:48:19 +02:00
|
|
|
f.write('\t\tvar ' + name + ' = new armory.logicnode.' + node_type + '(this);\n')
|
2017-11-09 19:47:10 +01:00
|
|
|
|
2018-11-04 05:05:52 +01:00
|
|
|
# Handle Function Nodes
|
|
|
|
if node_type == 'FunctionNode':
|
|
|
|
f.write('\t\tthis.functionNodes.set("' + name + '", ' + name + ');\n')
|
|
|
|
function_nodes[name] = node
|
|
|
|
elif node_type == 'FunctionOutputNode':
|
|
|
|
f.write('\t\tthis.functionOutputNodes.set("' + name + '", ' + name + ');\n')
|
|
|
|
# Index function output name by corresponding function name
|
|
|
|
function_node_outputs[node.function_name] = name
|
|
|
|
|
2021-06-28 12:07:57 +02:00
|
|
|
wrd = bpy.data.worlds['Arm']
|
|
|
|
|
2018-06-28 22:39:23 +02:00
|
|
|
# Watch in debug console
|
2021-06-28 12:07:57 +02:00
|
|
|
if node.arm_watch and wrd.arm_debug_console:
|
2018-06-28 22:39:23 +02:00
|
|
|
f.write('\t\t' + name + '.name = "' + name[1:] + '";\n')
|
|
|
|
f.write('\t\t' + name + '.watch(true);\n')
|
|
|
|
|
2021-07-25 20:13:47 +02:00
|
|
|
elif use_live_patch:
|
2021-06-28 12:07:57 +02:00
|
|
|
f.write('\t\t' + name + '.name = "' + name[1:] + '";\n')
|
|
|
|
f.write(f'\t\tthis.nodes["{name[1:]}"] = {name};\n')
|
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
# Properties
|
2021-07-24 20:17:29 +02:00
|
|
|
for prop_py_name, prop_hx_name in arm.node_utils.get_haxe_property_names(node):
|
|
|
|
prop = arm.node_utils.haxe_format_prop_value(node, prop_py_name)
|
|
|
|
f.write('\t\t' + name + '.' + prop_hx_name + ' = ' + prop + ';\n')
|
2020-02-12 13:51:31 +01:00
|
|
|
|
2021-07-24 13:36:16 +02:00
|
|
|
# Avoid unnecessary input/output array resizes
|
|
|
|
f.write(f'\t\t{name}.preallocInputs({len(node.inputs)});\n')
|
|
|
|
f.write(f'\t\t{name}.preallocOutputs({len(node.outputs)});\n')
|
2020-02-12 13:51:31 +01:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
# Create inputs
|
2021-07-24 13:36:16 +02:00
|
|
|
for idx, inp in enumerate(node.inputs):
|
2021-01-17 00:23:02 +01:00
|
|
|
# True if the input is connected to a unlinked reroute
|
|
|
|
# somewhere down the reroute line
|
|
|
|
unconnected = False
|
|
|
|
|
|
|
|
# Is linked -> find the connected node
|
2016-09-28 00:00:59 +02:00
|
|
|
if inp.is_linked:
|
2017-04-02 23:26:27 +02:00
|
|
|
n = inp.links[0].from_node
|
2017-04-03 22:29:46 +02:00
|
|
|
socket = inp.links[0].from_socket
|
2021-01-17 00:23:02 +01:00
|
|
|
|
|
|
|
# Follow reroutes first
|
|
|
|
while n.type == "REROUTE":
|
|
|
|
if len(n.inputs) == 0 or not n.inputs[0].is_linked:
|
|
|
|
unconnected = True
|
2017-04-03 22:29:46 +02:00
|
|
|
break
|
2021-01-17 00:23:02 +01:00
|
|
|
|
|
|
|
socket = n.inputs[0].links[0].from_socket
|
|
|
|
n = n.inputs[0].links[0].from_node
|
|
|
|
|
|
|
|
if not unconnected:
|
|
|
|
if (inp.bl_idname == 'ArmNodeSocketAction' and socket.bl_idname != 'ArmNodeSocketAction') or \
|
|
|
|
(socket.bl_idname == 'ArmNodeSocketAction' and inp.bl_idname != 'ArmNodeSocketAction'):
|
|
|
|
arm.log.warn(f'Sockets do not match in logic node tree "{group_name}": node "{node.name}", socket "{inp.name}"')
|
|
|
|
|
|
|
|
inp_name = build_node(n, f)
|
|
|
|
for i in range(0, len(n.outputs)):
|
|
|
|
if n.outputs[i] == socket:
|
|
|
|
inp_from = i
|
2021-07-24 13:36:16 +02:00
|
|
|
from_type = socket.arm_socket_type
|
2021-01-17 00:23:02 +01:00
|
|
|
break
|
|
|
|
|
|
|
|
# Not linked -> create node with default values
|
2016-09-28 00:00:59 +02:00
|
|
|
else:
|
2017-04-02 23:26:27 +02:00
|
|
|
inp_name = build_default_node(inp)
|
2017-04-03 22:29:46 +02:00
|
|
|
inp_from = 0
|
2021-07-24 13:36:16 +02:00
|
|
|
from_type = inp.arm_socket_type
|
2021-01-17 00:23:02 +01:00
|
|
|
|
2019-07-22 19:36:00 +02:00
|
|
|
# The input is linked to a reroute, but the reroute is unlinked
|
2021-01-17 00:23:02 +01:00
|
|
|
if unconnected:
|
2019-07-22 19:36:00 +02:00
|
|
|
inp_name = build_default_node(inp)
|
|
|
|
inp_from = 0
|
2021-07-24 13:36:16 +02:00
|
|
|
from_type = inp.arm_socket_type
|
2021-01-17 00:23:02 +01:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
# Add input
|
2021-07-25 20:13:47 +02:00
|
|
|
f.write(f'\t\t{"var __link = " if use_live_patch else ""}armory.logicnode.LogicNode.addLink({inp_name}, {name}, {inp_from}, {idx});\n')
|
|
|
|
if use_live_patch:
|
2021-07-24 13:36:16 +02:00
|
|
|
to_type = inp.arm_socket_type
|
2021-07-26 00:02:54 +02:00
|
|
|
f.write(f'\t\t__link.fromType = "{from_type}";\n')
|
|
|
|
f.write(f'\t\t__link.toType = "{to_type}";\n')
|
|
|
|
f.write(f'\t\t__link.toValue = {arm.node_utils.haxe_format_socket_val(inp.get_default_value())};\n')
|
2020-02-12 13:51:31 +01:00
|
|
|
|
2017-04-03 22:29:46 +02:00
|
|
|
# Create outputs
|
2021-07-24 13:36:16 +02:00
|
|
|
for idx, out in enumerate(node.outputs):
|
|
|
|
# Linked outputs are already handled after iterating over inputs
|
|
|
|
# above, so only unconnected outputs are handled here
|
|
|
|
if not out.is_linked:
|
2021-07-25 20:13:47 +02:00
|
|
|
f.write(f'\t\t{"var __link = " if use_live_patch else ""}armory.logicnode.LogicNode.addLink({name}, {build_default_node(out)}, {idx}, 0);\n')
|
|
|
|
if use_live_patch:
|
2021-07-24 13:36:16 +02:00
|
|
|
out_type = out.arm_socket_type
|
2021-07-26 00:02:54 +02:00
|
|
|
f.write(f'\t\t__link.fromType = "{out_type}";\n')
|
|
|
|
f.write(f'\t\t__link.toType = "{out_type}";\n')
|
|
|
|
f.write(f'\t\t__link.toValue = {arm.node_utils.haxe_format_socket_val(out.get_default_value())};\n')
|
2017-04-03 22:29:46 +02:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
return name
|
2019-07-21 20:52:52 +02:00
|
|
|
|
2019-07-22 20:00:26 +02:00
|
|
|
# Expects an output socket
|
|
|
|
# It first checks all outgoing links for non-reroute nodes and adds them to a list
|
|
|
|
# Then it recursively checks all the discoverey reroute nodes
|
|
|
|
# Returns all non reroute nodes which are directly or indirectly connected to this output.
|
2019-07-22 19:36:00 +02:00
|
|
|
def collect_nodes_from_output(out, f):
|
2019-07-21 20:52:52 +02:00
|
|
|
outputs = []
|
2019-07-22 19:36:00 +02:00
|
|
|
reroutes = []
|
|
|
|
# skipped if there are no links
|
|
|
|
for l in out.links:
|
|
|
|
n = l.to_node
|
|
|
|
if n.type == 'REROUTE':
|
|
|
|
# collect all rerouts and process them later
|
|
|
|
reroutes.append(n)
|
|
|
|
else:
|
|
|
|
# immediatly add the current node
|
|
|
|
outputs.append(build_node(n, f))
|
|
|
|
for reroute in reroutes:
|
|
|
|
for o in reroute.outputs:
|
|
|
|
outputs = outputs + collect_nodes_from_output(o, f)
|
2019-07-21 20:52:52 +02:00
|
|
|
return outputs
|
2020-02-12 13:51:31 +01:00
|
|
|
|
2016-09-23 00:34:42 +02:00
|
|
|
def get_root_nodes(node_group):
|
2016-09-28 00:00:59 +02:00
|
|
|
roots = []
|
2017-04-02 23:26:27 +02:00
|
|
|
for node in node_group.nodes:
|
2017-04-08 00:34:45 +02:00
|
|
|
if node.bl_idname == 'NodeUndefined':
|
|
|
|
arm.log.warn('Undefined logic nodes in ' + node_group.name)
|
|
|
|
return []
|
2017-04-02 23:26:27 +02:00
|
|
|
if node.type == 'FRAME':
|
|
|
|
continue
|
2017-03-06 02:29:03 +01:00
|
|
|
linked = False
|
2017-04-02 23:26:27 +02:00
|
|
|
for out in node.outputs:
|
|
|
|
if out.is_linked:
|
2017-03-06 02:29:03 +01:00
|
|
|
linked = True
|
|
|
|
break
|
|
|
|
if not linked: # Assume node with no connected outputs as roots
|
2017-04-02 23:26:27 +02:00
|
|
|
roots.append(node)
|
2016-09-28 00:00:59 +02:00
|
|
|
return roots
|
2016-09-23 00:34:42 +02:00
|
|
|
|
2020-06-10 14:25:01 +02:00
|
|
|
def build_default_node(inp: bpy.types.NodeSocket):
|
|
|
|
"""Creates a new node to give a not connected input socket a value"""
|
2020-09-06 19:06:28 +02:00
|
|
|
is_custom_socket = isinstance(inp, arm.logicnode.arm_sockets.ArmCustomSocket)
|
|
|
|
|
|
|
|
if is_custom_socket:
|
2020-06-10 14:25:01 +02:00
|
|
|
# ArmCustomSockets need to implement get_default_value()
|
|
|
|
default_value = inp.get_default_value()
|
2020-09-06 19:06:28 +02:00
|
|
|
inp_type = inp.arm_socket_type # any custom socket's `type` is "VALUE". might as well have valuable type information for custom nodes as well.
|
|
|
|
else:
|
2020-09-16 16:39:35 +02:00
|
|
|
if hasattr(inp, 'default_value'):
|
|
|
|
default_value = inp.default_value
|
|
|
|
else:
|
|
|
|
default_value = None
|
2020-09-06 19:06:28 +02:00
|
|
|
inp_type = inp.type
|
2020-06-10 14:25:01 +02:00
|
|
|
|
2021-07-18 22:28:32 +02:00
|
|
|
default_value = arm.node_utils.haxe_format_socket_val(default_value, array_outer_brackets=False)
|
2020-09-14 23:11:03 +02:00
|
|
|
|
2020-09-06 19:06:28 +02:00
|
|
|
if inp_type == 'VECTOR':
|
2021-07-18 22:28:32 +02:00
|
|
|
return f'new armory.logicnode.VectorNode(this, {default_value})'
|
2021-06-15 23:06:43 +02:00
|
|
|
elif inp_type == 'ROTATION': # a rotation is internally represented as a quaternion.
|
2021-08-18 17:04:00 +02:00
|
|
|
return f'new armory.logicnode.RotationNode(this, {default_value})'
|
2021-07-18 22:28:32 +02:00
|
|
|
elif inp_type in ('RGB', 'RGBA'):
|
|
|
|
return f'new armory.logicnode.ColorNode(this, {default_value})'
|
2020-09-06 19:06:28 +02:00
|
|
|
elif inp_type == 'VALUE':
|
|
|
|
return f'new armory.logicnode.FloatNode(this, {default_value})'
|
|
|
|
elif inp_type == 'INT':
|
|
|
|
return f'new armory.logicnode.IntegerNode(this, {default_value})'
|
|
|
|
elif inp_type == 'BOOLEAN':
|
2021-07-18 22:28:32 +02:00
|
|
|
return f'new armory.logicnode.BooleanNode(this, {default_value})'
|
2020-09-06 19:06:28 +02:00
|
|
|
elif inp_type == 'STRING':
|
|
|
|
return f'new armory.logicnode.StringNode(this, {default_value})'
|
|
|
|
elif inp_type == 'NONE':
|
|
|
|
return 'new armory.logicnode.NullNode(this)'
|
|
|
|
elif inp_type == 'OBJECT':
|
|
|
|
return f'new armory.logicnode.ObjectNode(this, {default_value})'
|
|
|
|
elif is_custom_socket:
|
|
|
|
return f'new armory.logicnode.DynamicNode(this, {default_value})'
|
|
|
|
else:
|
|
|
|
return 'new armory.logicnode.NullNode(this)'
|