1
$\begingroup$

I am confused by the error:

File "main", line 113, in TypeError: 'SCA_PythonController' object is not subscriptable Python script error - object 'Empty', controller 'Python': Traceback (most recent call last):

The code seemed to work beforehand, which is the confusing part.

The line I get the error refers to:

for ii in range(cont['DnpolymeraseNum']):

Full code:

cont = bge.logic.getCurrentController()

input = []
for i in range(2):
    input.append([])
    for ii in range(cont['DnpolymeraseNum']):
        if i == 1:
            input[i].append([0,0,0,0,0,0])
        if i == 0:
            input[i].append([0,0,0,0,0,0,0,0])

This piece of code was working before, I'm not sure as to why it isn't working now. I am aware suscriptable code describes objects containing objects, such as lists or tuples, I'm just not sure how this relates to the sensor controller actuator controller as I have not used any actuators in the game logic, and why I am getting this error after it worked beforehand.

I have an idea that it maybe because I have called the controller in the line of code; but this worked fine beforehand and I was able to access the property.

After looking around, common mistakes may include '[]' instead of '()'to implement the code, only this doesn't seem to be the problem here.

I have tried:

own = cont.owner my_property=own['DnpolymeraseNum']

To see if that accesses the game property and overrides this error somehow, but to no avail. A new error will appear as a result of me perhaps overlooking something:

File "main", line 11, in KeyError: 'value = gameOb[key]: KX_GameObject, key "DnpolymeraseNum" does not exist' Python script error - object 'Empty', controller 'Python'

Does anyone have an idea what I am doing/have done wrong?

Your answers and time are much appreciated, thanks.

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.