OS: Win11
PsychoPy version: 2023.2.3
Standard Standalone Installation? y
Do you want it to also run online? n
What are you trying to achieve?:
I would really appreciate any help with this!
Currently my task is working great. However, I am struggling with displaying the total number of credits at the end of the task. It counts and stores them correctly in the CSV. But, for some reason, I cannot display it at the end as a text component (no matter what I try).
Begin experiment:
credit = 0
Total_credits = 0
End routine: (To clarify, the Gamefeedback is in another text component, and that works perfectly!)
if key_resp_28.keys == ‘y’:
credit += Comb_list[0]
GameFeedback = ‘Well done! You answered the question correctly and won ’ + str(Comb_list[0]) + ’ credit(s)!’
winnings = ‘Reward’ + str(Comb_list[0]) + ‘.png’
thisExp.addData(‘Total_credits’, credit)
else:
GameFeedback = ‘Sadly, your answer was wrong. Better luck next time!’
winnings = ‘Nothing1.png’
On the next routine on Game3 (before the text is displayed - on end routine):
msg = “You have finished the task. You won " + str(‘Total_credits’) + " credits. Press space to end”
msg is in the text component.
It is saved in the csv as Total_credits
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
20
24
25
31
41
42
52
53
And I want to display that last column since that is the total at the end.
What did you try to make it work?:
I have tried:
- $Total_credits (only) in the text component.
- Total_credits instead of str().
- str(credit)) when saving to add Data
- Initialising the variable with = 0, [], and not at all.
- removing the str in the msg message so simply + ‘Total_credits’
- Adding msg text in a different routine (e.g., beginning the routine with it instead of before, and initialising it at the beginning).
Link to the most relevant existing thread you have found:
What specifically went wrong when you tried that?
Displays either:
- 0
- Total_credits
- msg
- [ ]
