UPBGE / UPBGE-logicnodes

A Node-based Logic system for UPBGE 2.8+
Other
53 stars 18 forks source link

ERROR in generation #98

Open cNori opened 6 months ago

cNori commented 6 months ago
[ERROR] KX_PythonComponent[Test] - Failed to invoke the start callback.
Traceback (most recent call last):
  File "D:\UPGEProject\Main.blend\nl_test.py", line 85, in start
  File "D:\UPGEProject\Main.blend\nl_test.py", line 18, in __init__
ImportError: cannot import name 'ULFPSFactor' from 'uplogic.nodes.parameters' (D:\upbge-0.36.1-windows-x86_64\3.6\python\lib\site-packages\uplogic\nodes\parameters\__init__.py)
Blender Game Engine Finished
# MACHINE GENERATED
import bge, bpy, sys
import mathutils
import math
from collections import OrderedDict

class TestWrapper():

    def __init__(self, game_object, exec_cond="", startup=False):
        from uplogic import nodes, utils
        from uplogic.nodes.logictree import ULLogicTree
        from uplogic.utils import OPERATORS, LOGIC_OPERATORS
        from uplogic.nodes.actions import ULPrintValue
        from uplogic.nodes.actions import ULApplyMovement
        from uplogic.nodes.conditions import ULKeyPressed
        from uplogic.nodes.conditions import ULOnUpdate
        from uplogic.nodes.parameters import ULFPSFactor
        from uplogic.nodes.parameters import ULMath

        self.condition = exec_cond
        owner = self.owner = game_object
        network = self.network = ULLogicTree()
        ACT0000 = ULPrintValue()
        ACT0001 = ULApplyMovement()
        CON0002 = ULKeyPressed()
        CON0003 = ULOnUpdate()
        PAR0004 = ULFPSFactor()
        PAR0005 = ULMath()
        ACT0000.msg_type = "INFO"
        ACT0000.condition = CON0002
        ACT0000.value = "1"
        ACT0001.local = True
        ACT0001.condition = ACT0000.OUT
        ACT0001.game_object = "NLO:U_O"
        ACT0001.movement = PAR0005.OUT
        CON0002.pulse = True
        CON0002.key_code = bge.events.WKEY
        PAR0005.operator = OPERATORS.get("MUL")
        PAR0005.operand_a = PAR0004.TIMEFACTOR
        PAR0005.operand_b = 2.0
        network.add_cell(CON0002)
        network.add_cell(PAR0004)
        network.add_cell(ACT0000)
        network.add_cell(CON0003)
        network.add_cell(PAR0005)
        network.add_cell(ACT0001)

        owner["IGNLTree_Test"] = network
        network._owner = owner
        network.setup()
        network.stopped = not owner.get('NL__Test')
        self.consumed = startup

    def evaluate(self):
        if self.consumed:
            return
        owner = self.owner
        if self.condition:
            cond = owner[self.condition]
            if not cond: return
        network = self.network
        if network.stopped: return
        shutdown = network.evaluate()
        if shutdown is True:
            self.consumed = True

class Test(bge.types.KX_PythonComponent):
    args = OrderedDict([
        ("Only Run At Startup", False),
        ("Execution Condition", "")
    ])

    def start(self, args):
        self.logictree = TestWrapper(
            self.object,
            exec_cond=args["Execution Condition"],
            startup=args["Only Run At Startup"]
        )
        self.logictree.evaluate()

    def update(self):
        if not self.logictree.consumed:
            self.logictree.evaluate()

def get_tree(obj):
    return TestWrapper(obj)

 Run At Startup", False),
        ("Execution Condition", "")
    ])

    def start(self, args):
        self.logictree = TestWrapper(
            self.object,
            exec_cond=args["Execution Condition"],
            startup=args["Only Run At Startup"]
        )
        self.logictree.evaluate()

    def update(self):
        if not self.logictree.consumed:
            self.logictree.evaluate()

def get_tree(obj):
    return TestWrapper(obj)

nodes image