Hi all
I’ve been making a system that allows me to create combinations of objects from messages sent via a mouseclick. The system works great but generates Clist errors when more than one ‘bundle’ of objects is generated. To iron out some problems I made a .blend that focusses on this.
Here is the code:
import bge, flexicomp_rbc as rbc
#CREATE AND JOIN SHIP PARTS###########################
PpositionName = "positionName"
def Create():
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
objList = scene.objects
owner = cont.owner
sensor0 = cont.sensors["Main"]
if not sensor0.positive:
return
MessageShipNameBody = sensor0.bodies
MessageShipName = MessageShipNameBody[0]
positionName = owner.get(PpositionName)
playerShip = scene.addObject(MessageShipName, positionName)
playerShip["Cindex"] = owner["cIndex"]
playerShip["player"] = owner["player"]
sensor1 = cont.sensors["Left"]
if not sensor1.positive:
return
MessageLeftBody = sensor1.bodies
MessageLeft = MessageLeftBody[0]
Left = [i for i in playerShip.children if "mountPointLeft" in i]
payloadLeft = scene.addObject(MessageLeft, Left[0])
const = rbc.SixDoF(playerShip, payloadLeft, (0.0, 0.0, 0.0))
const.limit()
const.limitRot()
payloadLeft["const"] = const
payloadLeft["Cindex"] = owner["cIndex"]
payloadLeft["player"] = owner["player"]
#PART MANAGEMENT################################################
def End_constraint_custom():
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
owner = cont.owner
owner["cIndex_value"] = owner.parent["cIndex"]
MouseL = cont.sensors["Mouse"]
MouseM = cont.sensors["Mouse1"]
Message4 = cont.actuators["Message4"]
if not MouseL.positive:
return
if not MouseM.positive:
return
Message4.subject = str("end")
Message4.body = str(owner["cIndex_value"])
cont.activate(Message4)
#IN UI (SHIP)
def End(cont):
owner = cont.owner
sensor = cont.sensors["Message2"]
sensorBody = sensor.bodies
sensorBodyMessage = sensorBody[0]
if sensorBodyMessage == str(owner["Cindex"]):
owner.endObject()
#IN UI (PAYLOAD)
def End_constraint(cont):
owner = cont.owner
const = owner.get("const", None)
sensor = cont.sensors["Message1"]
sensorBody = sensor.bodies
sensorBodyMessage = sensorBody[0]
if sensorBodyMessage == str(owner["Cindex"]):
if const and const.valid():
const.end()
owner.endObject()
Should I care about this if it works? If not, how do I go about stopping said errors? I am thinking about a try/except routine but I’m a little bit confused as to where the problem comes from.
Thanks for your time
Paul
Attachments
parent_testerB.blend (576 KB)