Arcade Toon Airplane: help to update scripts SOLVED

Hello everyone!

I guess some of you know about my efforts to keep 14&20 up to date. Right now I’m cleaning it, kind of restarting from scratch.

The attached .blend file print the following errors:

Blender Game Engine Started

Method getActuator(string) is deprecated, please use the actuators[string] property instead.
moveCont:32
Method getOwner() is deprecated, please use the owner property instead.
moveCont:34
Method getOrientation() is deprecated, please use the orientation property instead.
moveCont:39
Method getForce() is deprecated, please use the force and the useLocalForce properties instead.
moveCont:45
Method setForce() is deprecated, please use the force and the useLocalForce properties instead.
moveCont:45
Method setDLoc() is deprecated, please use the dLoc and the useLocalDLoc properties instead.
moveCont:48
Method setDRot() is deprecated, please use the dRot and the useLocalDRot properties instead.
moveCont:51
Method GameLogic.addActiveActuator(act, bool) is deprecated, please use controller.activate(act) or controller.deactivate(act) instead.
moveCont:54
Method setPitch() is deprecated, please use the pitch property instead.
soundCont:32
Method setState() is deprecated, please use the state property instead.
moveCont:41

Blender Game Engine Finished

Right now i have two scrips in action the MoveCont one:

import GameLogic
import math
import Blender
from Blender import Mathutils
from Blender.Mathutils import *

script by Leandro Cassa

this script is to control the plane pitch, roll and movement

also has a crash control if you break any restrictions

global variable to define if the plane should or not crash according

to the restrictions here defined

GameLogic.crash = 1

get angle in the Matrix Y axis

def getYAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().y

get angle in the Matrix X axis

def getXAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().x

get angle in the Matrix Z axis

def getZAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().z

cont = GameLogic.getCurrentController()
act = cont.getActuator(“pythonAct”)

gets the object who owns the actuator

obj = cont.getOwner()

crashAngle = 75

Crash Logic!

if (getYAngle(obj.getOrientation()) > crashAngle or getYAngle(obj.getOrientation()) < -crashAngle or getXAngle(obj.getOrientation()) > crashAngle or getXAngle(obj.getOrientation()) < -crashAngle and GameLogic.crash) :
# plane is crashing now, nothing you can do
obj.setState(1<<1)

Game Logic

else:
# keep the plane flying, set Z force of 9.81 on the bottom of the plane
act.setForce(act.getForce()[0], act.getForce()[1], 9.81, 0)

# keep the plane moving forward (engine)
act.setDLoc(0, 0.2, 0, 1)

# turns the plane according to Y axis rotation angle
act.setDRot(0, 0, -getYAngle(obj.getOrientation())/5000, 0)

# activate actuator
GameLogic.addActiveActuator(act,1)

And the SoundCout one:

import GameLogic
import math
import Blender
from Blender import Mathutils
from Blender.Mathutils import *

## script by Leandro Cassa
## this script is to control the plane pitch, roll and movement
## also has a crash control if you break any restrictions

# get angle in the Matrix Y axis
def getYAngle(matrix):
    tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
    return tempMatrix.transpose().toEuler().y

# get angle in the Matrix X axis
def getXAngle(matrix):
    tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
    return tempMatrix.transpose().toEuler().x

# get angle in the Matrix Z axis
def getZAngle(matrix):
    tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
    return tempMatrix.transpose().toEuler().z


cont = GameLogic.getCurrentController()
act = cont.getActuator("soundAct")
# gets the object who owns the actuator
obj = cont.getOwner()

act.setPitch(float(getXAngle(obj.getOrientation())/120) + 1)

# activate actuator
GameLogic.addActiveActuator(act,1)

Can anyone help me to fix this?

Thank you very much,

Ortiz

Attachments

ToonArcadePlaneB.blend (372 KB)

Hi Thorgal,

these are just warnings. The text describes what the alternative for the depricated methods are.

Examples:
“Method getActuator(string) is deprecated, please use the actuators[string] property instead.
moveCont:32”

 
act = cont.getActuator("pythonAct") # will be
act = cont.actuator["pythonAct"]

another one:
“Method getOwner() is deprecated, please use the owner property instead.
moveCont:34”

 
obj = cont.getOwner() # will be
obj = cont.owner

I hope it helps

Hi Monster! I keep hunting the warnings, thank you.

I did what you said and modified the codelines you said. Now my MoveCont script is like that:

import GameLogic
import math
import Blender
from Blender import Mathutils
from Blender.Mathutils import *

script by Leandro Cassa

this script is to control the plane pitch, roll and movement

also has a crash control if you break any restrictions

global variable to define if the plane should or not crash according

to the restrictions here defined

GameLogic.crash = 1

get angle in the Matrix Y axis

def getYAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().y

get angle in the Matrix X axis

def getXAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().x

get angle in the Matrix Z axis

def getZAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().z

cont = GameLogic.getCurrentController()
act = cont.actuator[“pythonAct”]

gets the object who owns the actuator

obj = cont.owner

crashAngle = 75

Crash Logic!

if (getYAngle(obj.getOrientation()) > crashAngle or getYAngle(obj.getOrientation()) < -crashAngle or getXAngle(obj.getOrientation()) > crashAngle or getXAngle(obj.getOrientation()) < -crashAngle and GameLogic.crash) :
# plane is crashing now, nothing you can do
obj.setState(1<<1)

Game Logic

else:
# keep the plane flying, set Z force of 9.81 on the bottom of the plane
act.setForce(act.getForce()[0], act.getForce()[1], 9.81, 0)

# keep the plane moving forward (engine)
act.setDLoc(0, 0.2, 0, 1)

# turns the plane according to Y axis rotation angle
act.setDRot(0, 0, -getYAngle(obj.getOrientation())/5000, 0)

# activate actuator
GameLogic.addActiveActuator(act,1) 

But

I guess this is not enough because now i have the following console warnings/errors:

Blender Game Engine Started

Python script error from controller “pythonCont#CONTR#2”:
Traceback (most recent call last):
File “moveCont”, line 32, in <module>
AttributeError: ‘SCA_PythonController’ object has no attribute ‘actuator’
Method getActuator(string) is deprecated, please use the actuators[string] property instead.
soundCont:28
Method getOwner() is deprecated, please use the owner property instead.
soundCont:30
Method getOrientation() is deprecated, please use the orientation property instead.
soundCont:32
Method setPitch() is deprecated, please use the pitch property instead.
soundCont:32
Method GameLogic.addActiveActuator(act, bool) is deprecated, please use controller.activate(act) or controller.deactivate(act) instead.
soundCont:35
Python script error from controller “pythonCont#CONTR#2”:
Traceback (most recent call last):
File “moveCont”, line 32, in <module>
AttributeError: ‘SCA_PythonController’ object has no attribute ‘actuator’
Python script error from controller “pythonCont#CONTR#2”:
Traceback (most recent call last):
File “moveCont”, line 32, in <module>
AttributeError: ‘SCA_PythonController’ object has no attribute ‘actuator’
Python script error from controller “pythonCont#CONTR#2”:
Traceback (most recent call last):
File “moveCont”, line 32, in <module>
AttributeError: ‘SCA_PythonController’ object has no attribute ‘actuator’
Python script error from controller “pythonCont#CONTR#2”:
Traceback (most recent call last):
File “moveCont”, line 32, in <module>

<<<And it keeps repeating this many times and the plane didn’t change to state 2 also.
I guess i need to do the same thing you did for another lines :o. So may question is:

How can i keep this kind of debug info:

Method getActuator(string) is deprecated, please use the actuators[string] property instead.
moveCont:32
Method getOwner() is deprecated, please use the owner property instead.
moveCont:34
Method getOrientation() is deprecated, please use the orientation property instead.
moveCont:39
Method getForce() is deprecated, please use the force and the useLocalForce properties instead.
moveCont:45
Method setForce() is deprecated, please use the force and the useLocalForce properties instead.
moveCont:45
Method setDLoc() is deprecated, please use the dLoc and the useLocalDLoc properties instead.
moveCont:48
Method setDRot() is deprecated, please use the dRot and the useLocalDRot properties instead.
moveCont:51
Method GameLogic.addActiveActuator(act, bool) is deprecated, please use controller.activate(act) or controller.deactivate(act) instead.
moveCont:54
Method setPitch() is deprecated, please use the pitch property instead.
soundCont:32
Method setState() is deprecated, please use the state property instead.
moveCont:41

And fix the script line by line… I mean… Is it possible trying to fix the script line by line and get rid of warnings one by one or i need to fix the whole thing in just one turn?

Thank you for your time,

Ortiz

Attachments

ToonArcadePlaneC.blend (372 KB)

There shouldnt be actuator but actuators.
You dont have to do whole process manually there is a script that does it for you. Go to Text> Text Plugins > Convert BGE 2.49. But this convert whole script this way you will avoid mistakes like that above.

Hey thank you! But it doesn’t work, console prints this (for ToonArcadePlaneB.blend):

“Traceback (most recent call last):
File “<string>”, line 1, in <module>
File “/Applications/blender-2.49a-OSX-10.5-py2.5-intel/blender.app/Contents/MacOS/./.blender/scripts/textplugin_convert_ge.py”, line 862, in <module>
import io
ImportError: No module named io”.

I’m missing something!

Does i need to install Python 3 to have this plugin working?
Does i need to highlight the whole script before using this plugin?

Alright here is the older version (Blender v. 2.48a) and the new version update for Blender 2.49b (no warnings) so if you’re a dumb person like me you can compare booth :wink:

2.48a

SCRIPT 1 (Function: to move)

import GameLogic
import math
import Blender
from Blender import Mathutils
from Blender.Mathutils import *

script by Leandro Cassa

this script is to control the plane pitch, roll and movement

also has a crash control if you break any restrictions

global variable to define if the plane should or not crash according

to the restrictions here defined

GameLogic.crash = 1

get angle in the Matrix Y axis

def getYAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().y

get angle in the Matrix X axis

def getXAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().x

get angle in the Matrix Z axis

def getZAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().z

cont = GameLogic.getCurrentController()
act = cont.actuators[“pythonAct”]

gets the object who owns the actuator

obj = cont.owner

crashAngle = 80

Crash Logic. It “crashes” the plane to another state.

if (getYAngle(obj.orientation) > crashAngle or getYAngle(obj.orientation) < -crashAngle or getXAngle(obj.orientation) > crashAngle or getXAngle(obj.orientation) < -crashAngle and GameLogic.crash) :
# plane is crashing now.
obj.state = 1<<1

Game Logic

else:
# keep the plane flying, set Z force of 9.81 on the bottom of the plane
act.force = [act.force[0], act.force[1], 9.81]

# keep the plane moving forward (engine)
#act.setDLoc(0, 0.01, 0, 1)
act.dLoc = [0, 0.01, 0]

# turns the plane according to Y axis rotation angle
act.dRot = [0, 0, -getYAngle(obj.orientation)/5000 ]

# activate actuator
cont.activate(act)
#GameLogic.addActiveActuator(act,1)

2.49b version of the same script:

import GameLogic
import math
import Blender
from Blender import Mathutils
from Blender.Mathutils import *

Script by Leandro Cassa

Updated to Blender 2.49b by Andre Ortiz

this script is to control the plane pitch, roll and movement

also has a crash control if you break any restrictions

global variable to define if the plane should or not crash according

to the restrictions here defined

GameLogic.crash = 1

get angle in the Matrix Y axis

def getYAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().y

get angle in the Matrix X axis

def getXAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().x

get angle in the Matrix Z axis

def getZAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().z

cont = GameLogic.getCurrentController()
act = cont.actuators[“pythonAct”]

gets the object who owns the actuator

obj = cont.owner

crashAngle = 80

Crash Logic. It “crashes” the plane to another state.

if (getYAngle(obj.orientation) > crashAngle or getYAngle(obj.orientation) < -crashAngle or getXAngle(obj.orientation) > crashAngle or getXAngle(obj.orientation) < -crashAngle and GameLogic.crash) :
# plane is crashing now.
obj.state = 1<<1

Game Logic

else:
# keep the plane flying, set Z force of 9.81 on the bottom of the plane
act.force = [act.force[0], act.force[1], 9.81]

# keep the plane moving forward (engine)
#act.setDLoc(0, 0.01, 0, 1)
act.dLoc = [0, 0.05, 0]

# turns the plane according to Y axis rotation angle
act.dRot = [0, 0, -getYAngle(obj.orientation)/5000 ]

# activate actuator
cont.activate(act)
#GameLogic.addActiveActuator(act,1)
SCRIPT 2 (Function: set pitch sound according to airplane orientation)

2.48a

import GameLogic
import math
import Blender
from Blender import Mathutils
from Blender.Mathutils import *

script by Leandro Cassa

this script is to control the plane pitch, roll and movement

also has a crash control if you break any restrictions

get angle in the Matrix Y axis

def getYAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().y

get angle in the Matrix X axis

def getXAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().x

get angle in the Matrix Z axis

def getZAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().z

cont = GameLogic.getCurrentController()
act = cont.actuators[“soundAct”]

gets the object who owns the actuator

obj = cont.owner

act.pitch = float(getXAngle(obj.orientation)/120) + 1

activate actuator

cont.activate(act)
#GameLogic.addActiveActuator(act,1)

2.49b version of the same script:

import GameLogic
import math
import Blender
from Blender import Mathutils
from Blender.Mathutils import *

script by Leandro Cassa

Updated to Blender 2.49b by Andre Ortiz

this script is to control the plane pitch, roll and movement

also has a crash control if you break any restrictions

get angle in the Matrix Y axis

def getYAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().y

get angle in the Matrix X axis

def getXAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().x

get angle in the Matrix Z axis

def getZAngle(matrix):
tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
return tempMatrix.transpose().toEuler().z

cont = GameLogic.getCurrentController()
act = cont.actuators[“soundAct”]

gets the object who owns the actuator

obj = cont.owner

act.pitch = float(getXAngle(obj.orientation)/120) + 1

activate actuator

cont.activate(act)
#GameLogic.addActiveActuator(act,1)

RELATED POST: http://blenderartists.org/forum/showthread.php?p=1582160#post1582160