Experiment works locally but does not recognize custom (existing) function on Pavlovia

URL of experiment: Pavlovia

Description of the problem: This experiment was made in builder (v2021.v.1.14) with a custom function. The experiment works perfectly locally, but in Pavlovia it throws an error when the custom function is evoked. The error says that the function is not defined, but I can see that it is defined in line 723 of the compiled experiment.

Thanks in advance for the advice!

What is the custom function?

Have you defined it twice?

The custom function is makeText(). In the latest version, I defined it a second time because the previous error was an undefined function, and I thought the code was trying to use it before it was defined. In both cases, the code works locally but not on Pavlovia.

If you use the auto translate, you should define it in Before Experiment

In Begin Experiment it should be defined using

makeText = function(x) {


}

Thanks for the suggestion. I did this, and now I am getting an error that win is not defined. I would greatly appreciate any additional advice!
Screen Shot 2022-08-17 at 6.44.26 PM

Changing the definition of the function to

function makeText(clickN) {
    return new visual.TextStim({win: psychoJS.window, text: clickN, pos: getLoc, depth: (- 4.0), height: 0.03});
}

and replacing append with push in one line in your ‘every frame’ code, making it

allText.push(makeText(clickN))

makes it work (for me).

2 Likes

That did the trick! Thanks, @ajus!