Conditional start or end of components - problem translating to JavaScript

Unfortunately, when trying to compile my experiment I made with the builder to JS, the conditions in the conditional start are not translated correctly. That is, the value “True” of the boolean is translated to “True” instead of “true” which leads to an error in JS and when trying to upload the experiment to Pavlovia

I think you need the $ symbol in the beginning i.e. $code_valid
And also, $code_valid should suffice, no need for ==True

2 Likes

I have also experienced this problem and this solution has not worked for me, when run in Pavlovia the condition does not apply and the component is started at the start of the routine and not when the condition is met.

Please could you show a screenshot of your component?

This is how the component looks:

Also, this is controlled by the following custom code component:
In the Begin Routine tab:

show_consent = 0

In the Each Frame tab:

s1 = slider_1.getRating()
s2 = slider_2.getRating()
s3 = slider_3.getRating()
s4 = slider_4.getRating()
s5 = slider_5.getRating()
s6 = slider_6.getRating()

if s1 is not None:
    if s2 is not None:
        if s3 is not None:
            if s4 is not None:
                if s5 is not None:
                    if s6 is not None:
                        show_consent = 1

Maybe try it with true/false instead of 0/1.

Thank you very much, I have tried it but the result is the same.

Try using if s1: etc instead of if s1 is not None:

None doesn’t work well online

1 Like

That worked! Thank you very much.

1 Like