newX commands (and their arguments) are evaluated immediately so even if you were able to directly refer to the value of the Var element (which you can:
getVar("word_num").value) you wouldn’t necessarily get what you want, because the execution of a PennController trial (and of the commands on its elements) happens, well, whenever the trial is executed
You could do this instead:
newVar("random_word", variable["word_" + Math.floor(Math.random() * 12)] ).log(), newText("word", "").text( getVar("random_word") ).print()
newTrial("trial_prac", // ... word_num = Math.floor(Math.random() * 12), newText("word", variable["word_" + word_num]).print() //... ) .log("word_num", word_num)
EDIT: sorry, I just saw your second message. That’s a great solution (it’s actually cleaner than creating a variable within
newTrial like I suggest)
- This reply was modified 1 year, 4 months ago by Jeremy.