#allmethods.py
import bge
import serial
def init(self):
return
def currentMode(parent):
mode=parent[‘mode’]
childObj=parent[parent[‘child’]]
childObj.setParent(parent)
action=parent[‘action’]
if mode==1:
if action==1:
performAction="tilt"
elif action==0:
performAction="trans"
elif mode==2:
performAction="trans"
elif mode==3:
performAction="tilt"
return mode,childObj,performAction
def translation(empty,X,Y,Z):
if X and Y:
if Z:
X =X* 0.57735
Y = Y0.57735
Z = Z0.57735
else:
X =X* 0.7071
Y =Y* 0.7071
elif X and Z:
X =X* 0.7071
Z =Z* 0.7071
elif Y and Z:
Y =Y* 0.7071
Z =Z* 0.7071
# apply Movement
empty.applyMovement([X, Y, Z],1)
return
def tilt(self,empty,X,Y,Z):
Xc = .005
Yc = .005
Getting the rotation values.
X1 = -float(Xmovement) * Xc
Y1 = float(Ymovement) * Yc
print(“X:”,X)
print(“Y:”,Y)
Xpivot.applyRotation([0, 0, X1],0)
Ypivot.applyRotation([Y1,0, 0],1)
return
def calculation(self,empty,X,Y,Z): ### select the axis and pass only that
##### all text objects####
objAngle=obj["display angle"]
objMagStrength=obj["display strength"]
printCurrent=obj["printCurrent"]
objAngle['Text']=x
area=.09
default="0.5"
objMagStrength['Text']=default
if (default=="0"):
for i in range(1,6):
obj[''.join(['line',str(i)])].visible=False
elif(0<float(default)<=0.2):
for i in range(1,4):
obj[''.join(['line',str(i)])].visible=False
elif(0.2<float(default)<=0.5):
for i in range(1,2):
obj[''.join(['line',str(i)])].visible=False
w= 4*x*3.14
printCurrent["Text"]=.5*area*w*math.sin(w/2)
return
def selectObject(self,empty):
obj=bge.logic.getCurrentScene().objects
objCursor=obj[‘Cursor’]
objCoil=obj[‘coil’]
objMagnet=obj[‘horseshoe’]
detectCoil=objCursor.rayCast(objCoil,objCursor,2)
detectMagnet=objCursor.rayCast(objMagnet,objCursor,2)
if "coil" in detectCoil:
empty[empty[child]].removeParent(empty)
empty['child']="coil"
empty['mode']=3
elif "horseshoe" in detectMagnet:
empty[empty[child]].removeParent(empty)
empty['child']="horseshoe"
empty['mode']=3
return
Syntax error:
inconsistent use of tabs and spaces in indentation
in method tilt and translation after each of the if loops…
:S
indentation is correct… it works well in 2.49…
I am using 2.56…