I’m attempting to use a variable in a Penncontroller.Template function in order to keep track of how many selectors from a set are chosen in each trial. I made the variable global because, as I understand it, a local variable cannot be accessed and edited by multiple selectors. Since global variables don’t reset with each new trial, I manually included a getVar command at the top of the Template function to reset the value to 0 for each new trial. However, this manual reset to 0 doesn’t seem to be working (the last value of the variable carries over to the next trial), and I can’t figure out why. Do you have any insight as to why this may be the case?
There is a known bug with global Var elements which will be fixed with the release of PennController 1.7—I am not quite ready to make that release yet, but if you’re in a hurry I just published a version 1.7 alpha, you can sync it to your project following the steps described here and typing 1.7alpha in the branch field
Also, did you make sure to also call .settings.global() on the getVar just before you use set?
I’ve synced the project with the 1.7alpha version, but it still doesn’t seem to be working.
I called .settings.global() when I declared the variable — do I need to do it when I call getVar as well? Otherwise, I’m not sure what the issue may be.
Just a question, when you say that you included a getVar at the top of your Template function, do you mean inside or outside the nested PennController command (the one starting after =>)?
Feel free to share your code if the problem persists