What's the correct syntax?

I’m trying to come to terms with the changes in python in BGE 2.49.
I have reviewed and corrected all the code I have written.
All? Not exactly all.
The only piece of code that gives an error in the console is the following:

ob,hit,normal = player.rayCast( cam_par, player, 0.0, “”)

The error in the console is:

Method val = ob.attr is deprecated, please use val = ob[‘attr’] instead.
What’s the correct syntax?

The new syntax for properties look like this.





This is to differenciate between reserved properties like position, orientation, ect… and ones created by the user.

Yes I have understood that. The error message refers to val= ob [‘prop’] and not ob[‘prop’]=val ,though

I think it’s practically the same either way, for one of my scripts I got both types of deprecation messages and doing it just one way makes it disappear.

I think the other one is there because you’ll have to do things like.

ob.position=(ob['locX'], ob['locY'], ob['locZ'])

In other words you do the same thing to all properties that aren’t reserved properties I think.

pos = camera.getScreenPosition(cube)
Has the same problem It must be a bug
unless I’m just not getting it. But right now I just check ignore depreciation warnings.

I want to correct all the deprecation warnings because when 2.50 arrives the current code won’t be compatible with the new one.

I have the same problem as you…

I cannot see anything wrong with the syntax of the code from the original poster.

This must be a bug in the BGE.

I can’t figure out this warning either.

I get the same warning just printing the directory.

controller = GameLogic.getCurrentController()

act = controller.actuators["act"]

print dir(act)

I get this warning with rayCastTo(cube) or getScreenPosition(cube) or etc when cube is a KX_GameObject

Doesn’t seen to matter what method (ie python function) is used. Does anyone know how to use a KX_GameObject so it doesn’t return the warning?

Would be great if someone could confirm if we are using a false syntax or if this is a bug…
Strange to me is that this waring did not come up in 2.49RC3 but now in the Final version.

Here a small .blend that worked in 2.49RC3 without error and now returns errors in 2.49 Final.

It has two scenes one that sends Messages and the other one that receives it.
The logic is in the Camera of each scene.
make sure your in scene receive when you start.
use 1-Key,2-key and 3-Key to send messages…

MessageBoddyError.blend (148 KB)

This is a bug, I didnt realize Python used getattr so much for internal antrospection of game types. will fix for 2.49a

Thanx a lot. So I dont have to add it to the Bug tacker? - your already at it?