简体   繁体   中英

Lua unexpected identifier issue in VSC

i was transfering code from my tablet's ide to VSC to tweak it and continue it on PC but i've ran into an issue. I'm trying to define a variable by using local xyz = 0 but it keeps returning SyntaxError: Unexpected identifier when i try to run it but it worked perfectly fine on my mobile IDE. (on pc i'm using Visual Studio Code with the Lua extension by sumneko and on pc i was using an app called TouchLua+) debug console output

i've tried looking it up on google but there were no posts describing any similar issue

It's hard to say without more code or context(not familiar with the touchapp) but this as a standalone piece of lua is valid.

However notice your debug screenshot, you are executing a piece of lua with nodejs, Look at the cli

C:\ProgramFiles\nodejs\node.exe RPSbot.lua
                        ^          ^
                        |          |
                     Path to node  |
                                  your lua file given to the node.exe

Unsure if there is some other js process that you used on your tablet that ran lua via nodejs or you are trying this from js yourself. But nodejs is intended for javascript files.

Using node on this piece of code produces the same error. You should run this using the lua runtime. If you haven't already, you can download lua here , be sure to add it to your path if needed.

Then you can run it from cli as following:

lua RPSbot.lua

Or create a batch script to call it by name without lua before it, ie create a file called RPSbot.cmd or RPSbot.bat and place calling code in it lua RPSbot.lua . The calling code might need to use the full path to lua and your script. Then you can just run that batch script each time.

If it is intended to run trough node you might need to provide more code and/or context.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM