Browse Source

Fix some potential tracebacks in the Logic Nodes

pull/10/head
Adam Johnson 9 years ago
parent
commit
530d5efe74
  1. 12
      korman/nodes/node_conditions.py
  2. 6
      korman/nodes/node_core.py
  3. 11
      korman/nodes/node_messages.py

12
korman/nodes/node_conditions.py

@ -48,7 +48,9 @@ class PlasmaClickableNode(PlasmaNodeBase, bpy.types.Node):
# We do this because we might be exporting from a BO that is not actually the clickable object.
# Case: sitting modifier (exports from sit position empty)
if self.clickable:
clickable_bo = bpy.data.objects[self.clickable]
clickable_bo = bpy.data.objects.get(self.clickable, None)
if clickable_bo is None:
self.raise_error("invalid Clickable object: '{}'".format(self.clickable), tree)
clickable_so = exporter.mgr.find_create_object(plSceneObject, bl=clickable_bo)
# We're deep inside a potentially unrelated node tree...
exporter.export_coordinate_interface(clickable_so, clickable_bo)
@ -127,7 +129,9 @@ class PlasmaClickableRegionNode(PlasmaNodeBase, bpy.types.Node):
def convert_subcondition(self, exporter, tree, parent_bo, parent_so, logicmod):
# REMEMBER: parent_so doesn't have to be the actual region scene object...
region_bo = bpy.data.objects[self.region]
region_bo = bpy.data.objects.get(self.region, None)
if region_bo is None:
self.raise_error("invalid Region object: '{}'".format(self.region), tree)
region_so = exporter.mgr.find_create_key(plSceneObject, bl=region_bo).object
# Try to figure out the appropriate bounds type for the region....
@ -316,7 +320,9 @@ class PlasmaVolumeSensorNode(PlasmaNodeBase, bpy.types.Node):
# Don't forget to export the physical object itself!
# [trollface.jpg]
phys_bo = bpy.data.objects[self.region]
phys_bo = bpy.data.objects.get(self.region, None)
if phys_bo is None:
self.raise_error("invalid Region object: '{}'".format(self.region), tree)
simIface, physical = exporter.physics.generate_physical(phys_bo, so, self.bounds, "{}_VolumeSensor".format(bo.name))
physical.memberGroup = plSimDefs.kGroupDetector

6
korman/nodes/node_core.py

@ -17,6 +17,8 @@ import abc
import bpy
from PyHSPlasma import plMessage, plNotifyMsg
from ..exporter import ExportError
class PlasmaNodeBase:
def create_key_name(self, tree):
return "{}_{}".format(tree.name, self.name)
@ -121,6 +123,10 @@ class PlasmaNodeBase:
def poll(cls, context):
return (context.bl_idname == "PlasmaNodeTree")
def raise_error(self, message, tree):
final = "Plasma Node Tree '{}' Node '{}': {}".format(tree.name, self.name, message)
raise ExportError(final)
@property
def requires_actor(self):
return False

11
korman/nodes/node_messages.py

@ -161,26 +161,25 @@ class PlasmaAnimCmdMsgNode(PlasmaMessageNode, bpy.types.Node):
msg = plAnimCmdMsg()
# We're either sending this off to an AGMasterMod or a LayerAnim
error = ExportError("Node '{}' in '{}' specifies an invalid animation".format(self.name, tree.name))
if self.anim_type == "OBJECT":
obj = bpy.data.objects.get(self.object_name, None)
if obj is None:
raise error
self.raise_error("invalid object: '{}'".format(self.object_name), tree)
anim = obj.plasma_modifiers.animation
if not anim.enabled:
raise error
self.raise_error("invalid animation", tree)
target = exporter.mgr.find_create_key(plAGMasterMod, bl=obj, name=anim.display_name)
else:
material = bpy.data.materials.get(self.material_name, None)
if material is None:
raise error
self.raise_error("invalid material: '{}'".format(self.material_name), tree)
tex_slot = material.texture_slots.get(self.texture_name, None)
if tex_slot is None:
raise error
self.raise_error("invalid texture: '{}'".format(self.texture_name), tree)
name = "{}_{}_LayerAnim".format(self.material_name, self.texture_name)
target = exporter.mgr.find_create_key(plLayerAnimation, name=name, so=so)
if target is None:
raise error
raise RuntimeError()
msg.addReceiver(target)
# Check the enum properties to see what commands we need to add

Loading…
Cancel
Save