The default VEXcode VR project has some additional needed pieces to make sure VR works properly while running inside of the browser.
# Library imports
from vexcode import *
# Add project code in "main"
# CODE GOES HERE
# VR threads — Do not delete
Behind the scenes, we run a pre-processor to add “await” to commands as VR is using the asyncio library (https://docs.python.org/3/library/asyncio.html) to handle running multiple threads in VR and also handle all of the communication to the Pyodide runtime (https://github.com/iodide-project/pyodide) behind the scenes. This is on top of talking to the Playground interface to pass robot I/O back and forth.
Due to these libraries running behind the scenes, this is one of the reasons that looping commands require a brief (1ms) wait to run properly to ensure all of the parts of the system are staying in constant communication.
We’re continuing to develop improvements to VEXcode VR in the future to try and mitigate some of these limitations compared to standard Python.