SyntaxError: ' await' outside function?

Hey, I was needing a little bit of help on a line of code. I am more of a beginner in VexVR coding but have had experience with Lua Roblox coding.

My error is…

I can not seem to find what this SyntaxError means. I have already tried adding await functions outside of the parameters but I do not know if I have done it wrong.
Any help on this question would help.

I dont see the await, but what it means is you can’t use the await keyword outaide of an async function. Are you perhaps scrolled too far right?

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"
def main():
    # CODE GOES HERE

# VR threads — Do not delete
vr_thread(main())

Behind the scenes, we run a pre-processor to add “await” to commands as VR is using the asyncio library (asyncio — Asynchronous I/O — Python 3.11.4 documentation) to handle running multiple threads in VR and also handle all of the communication to the Pyodide runtime (GitHub - pyodide/pyodide: Pyodide is a Python distribution for the browser and Node.js based on WebAssembly) 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.

2 Likes