# Code not working on pavlovia

**URL:** <https://discourse.psychopy.org/t/code-not-working-on-pavlovia/20923>\
**Category:** Online experiments\
**Tags:** pavlovia\
**Created:** [March 2, 2021, 6:00pm UTC](https://discourse.psychopy.org/t/code-not-working-on-pavlovia/20923 "2021-03-02T18:00:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ozgezer](https://avatars.discourse-cdn.com/v4/letter/o/46a35a/32.png) [@ozgezer](https://discourse.psychopy.org/u/ozgezer)\
**Post date:** [March 2, 2021, 6:00pm UTC](https://discourse.psychopy.org/t/code-not-working-on-pavlovia/20923/1 "2021-03-02T18:00:10Z")

</div>

Hello everyone,

I have recently begun using PsychoPy and I have been trying to solve this problem for a while. I thought it might be nice to get ideas from others, any help or suggestion is very appreciated. Sorry for the long post. 😇

**URL of experiment:** [BoRec [PsychoPy]](https://run.pavlovia.org/ozgezer/borec)

**Description of the problem** : The code and experiments work perfectly locally, however, when I upload to Pavlovia instead of showing an image in every four trials (a star image to keep younger participants interested), it appears before every stimulus.

I created two pseudorandom lists of actual stimulus and I want to show the star image after every four trials without interrupting the sequential order of the randomized lists. I tried to manipulate the opacity of the slider and images but I encountered the error mentioned in [Unable to set specific duration for specific stimuli](https://discourse.psychopy.org/t/unable-to-set-specific-duration-for-specific-stimuli/20910) [[Unable to set specific duration for specific stimuli](https://discourse.psychopy.org/t/unable-to-set-specific-duration-for-specific-stimuli/20910)].

 ![ss1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/f/4/f4f9da75b28ce83bb4dbcaf2524b8fcb81709c7c.png)

Here, I created a code\* to check the trial number with help of a colleague. So, the star image routine would appear only after thisN trials. However, as I said it does not work as same as it works locally on PsychoPy and it does not give an error either.

\*Code:

```auto
if bodytrial.thisN == 4 or bodytrial.thisN==8 or bodytrial.thisN == 12 or bodytrial.thisN == 16:
    StarCheckLoop = 1
else: 
    StarCheckLoop=0

```

Also, I tried to use the crib sheet to prevent any script errors [https://docs.google.com/document/d/13jp0QAqQeFlYSjeZS0fDInvgaDzBXjGQNe4VNKbbNHQ/edit](https://docs.google.com/document/d/13jp0QAqQeFlYSjeZS0fDInvgaDzBXjGQNe4VNKbbNHQ/edit) however, it crashed and didn’t upload at all.

Finally, I also tried to use the time condition parameter to manipulate when the slider and actual stimulus would appear and when the star would appear. However, this makes the experiment stuck in initializing the experiment part and I couldn’t find the solution for this one either -this one was more complicated tbh-.

Thank you so much for any feedback or suggestions, sorry for the long post again.

Best wishes,  
Özge.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 2, 2021, 6:20pm UTC](https://discourse.psychopy.org/t/code-not-working-on-pavlovia/20923/2 "2021-03-02T18:20:40Z")

</div>

> [@ozgezer](#):
>
> `.thisN`

doesn’t work online.

---

<div class="post-metadata">

**Author:** ![ozgezer](https://avatars.discourse-cdn.com/v4/letter/o/46a35a/32.png) [@ozgezer](https://discourse.psychopy.org/u/ozgezer)\
**Post date:** [March 2, 2021, 6:51pm UTC](https://discourse.psychopy.org/t/code-not-working-on-pavlovia/20923/3 "2021-03-02T18:51:05Z")

</div>

Hi wakecarter,

Thank you for your reply. Do you have any idea how to overcome this issue without using thisN?

Best,  
Özge.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 3, 2021, 6:58am UTC](https://discourse.psychopy.org/t/code-not-working-on-pavlovia/20923/4 "2021-03-03T06:58:30Z")

</div>

Yes. Use a loop counter variable as per my crib sheet.

---

<div class="post-metadata">

**Author:** ![ozgezer](https://avatars.discourse-cdn.com/v4/letter/o/46a35a/32.png) [@ozgezer](https://discourse.psychopy.org/u/ozgezer)\
**Post date:** [March 3, 2021, 8:45am UTC](https://discourse.psychopy.org/t/code-not-working-on-pavlovia/20923/5 "2021-03-03T08:45:59Z")

</div>

Thanks a lot! That works perfectly!!
