Coding collecting points

Hello all,

I have a problem understanding coding collecting points.
In another program for experiments, my code works fine, but here I don’t know how to write them right.

Here is the code that works in Opensesame:

self.get('gleich'), self.get('response')

if (var.gleich == 1) and (var.response == 'space') or (var.gleich == 0) and (var.response == 'None'):  
		correct = 1
		correct = 0

response = var.response 
var.response_key = response
var.response_correct = correct


One point is to be awarded in each case if the number in the table of the respective trial is 1 and then the Space key is pressed or if the number is 0 and the Space key is not pressed.

In Psychopy I have tried various things, but somehow I lack the understanding of how to access the variable from the excel sheet. I made it so far that a new variable is created in the datasheet, but it is always 0.
Attached is the simple structure of the experiment as a screenshot.

It would be nice if anyone could give me some clues.


score = 0
if resp_keys.keys:
     if gleitch:
          score = 1
elif gleitch == 0:
     score = 1
thisExp.addData(‘Score’, score)

This is based on the assumption that the space bar is the only key response allowed.

I thinks I have a Go No go online demo with similar code to this.

Thank you very much for your quick response. Now I understand how the variables are accessed. Just had to change the name of the keyboard variable. Thank you! Thank you! Thank you!

score = 0
if key_resp.keys:                        # only 'space' is the allowed key
     if gleich:                          # the variable from the Excel sheet
          score = 1
elif gleich == 0:
     score = 1
thisExp.addData('score', score)