0

I'm sure this is deadly simple, but I'm new to Psychopy and Python, so here goes:

I have a conditions file similar to the following (in builder):

text correctAns trialType

text1 Ans1 TrialA

text2 Ans2 TrialB

When giving feeback to users after each trial, I'd like to give different feedback on A trialTypes as compared with B trialTypes. I can't find how to reference the trialType however.

What I'd like to know is what do I need rather than "trialType" in the code below:

if trialType == 'TrialA' msg="This was an A Trial!" else: msg="This was a B Trial!"

Thanks for your help! D (edited to correct code formatting on 23 Feb 2015)

Devin
  • 3
  • 3

1 Answers1

2

Make sure that the syntax is correct (indentation is relevant). Something like the following should do with your variable definitions:

if trialType == 'TrialA':
    msg = "This was an A Trial!"
else:
    msg = "This was a B Trial!"

Another option is to just add another column with your trial-type-specific message, which you can use for text display.

Cheers,

Axel

Axel Kohler
  • 131
  • 4
  • Thanks Axel. Sorry about the formatting, I didn't realize it'd be wiped out when I posted. That's actually what I tried, but I get a syntax error. Somehow I don't think that just using the column heading is sufficient. I've tried things like .thisTrial(TrialA) and $TrialA, but I can't get anything to work. Perhaps this is because I'm writing code in the builder? – Devin Feb 23 '15 at 21:57
  • Hi Devin. I've used similar code in Builder many times. In your current code, you are still missing the colon after the if clause. Did you just omit it? Otherwise, this will still generate an error. Just try to write a minimal Builder program that has one text component with "$msg" as text and one code component with the code above and a loop with your conditions file. Try to get it to work and build on this. – Axel Kohler Feb 24 '15 at 19:07