0
$\begingroup$

I'm using v2.69 and I get this error in my terminal:

AttributeError: 'SCA_PythonController' object has no attribute 'getOwner'

I'm using Linux.

The error in the line 21. Is the problem in my code or the version?

from GameLogic import * 
import GameLogic as GameLogic
#START THIS SETUP ONE TIME AS A SERVER AND ONE TIME AS A CLIENT

#BEVORE YOU START THIS SETUP AS A CLIENT REPLACE THE * IN THE 
#LINE BELOW WITH THE SERVER IP 
#(FOR EXAMPLE: GameLogic.IP = "192.123.100.1")



GameLogic.IP = "192.168.1.1"





#THE CODE BELOW SETS UP IF YOU PLAY THE CLIENT OR THE SERVER
#TO START THE SERVER PRESS F1 TO START THE CLIENT F2

cont = GameLogic.getCurrentController()
obj = cont.getOwner()
scene = getCurrentScene()
Server = cont.getSensor("F1")
Client = cont.getSensor("F2")

if Server.isPositive():
    Server = scene.getObjectList()["OBServer"]
    Server.Activ = 1
if Client.isPositive():
    Client = scene.getObjectList()["OBClient"]
    Client.Activ = 1
$\endgroup$
1
$\begingroup$

This is Python code written for BGE 2.49 and earlier.

You need to convert it to BGE 2.5+. This includes API changes and upgrade to Python 3.0.

To make it short:

.getOwner()      -> .owner
.getSensor("F1") -> .sensors["F1"]
.getObjectList() -> .objects
["OBServer"]     -> ["Server"] 
Server.Activ     -> Server["Activ"]

It looks like this is just a fragment of more logic.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.