PDA

View Full Version : Extension error loading lua script



Wintermute
February 12th, 2019, 18:25
Having an error trying to load a script thru an extension. I keep getting this error message in the console during loading: Script Error: [string "scripts/gmw.lua"]:1: '=' expected near '»'

I have stripped this extension down to bare minimum and I'm stuck. It's time for a new set of eyes to point out my stupid mistake. lol

Thanks and here's the .ext for debugging.

StoryWeaver
February 12th, 2019, 18:55
function onInit()
Debug.console("here")
End



Should be:

function onInit()
Debug.console("here")
end





There is no keyword in lua that matches what's in the code 'End', the keyword you want is 'end', all non-capital letters.

StoryWeaver
February 12th, 2019, 18:59
Let me recommend the following sources for lua:

https://docs.coronalabs.com/guide/start/introLua/index.html
https://www.tutorialspoint.com/lua/lua_overview.htm

Good luck with your coding. ;)

mattekure
February 12th, 2019, 19:03
You also have the file encoding set to UTF-8 BOM. Set it to just UTF-8. Its the file encoding thats throwing that weird error you mentioned.

mattekure
February 12th, 2019, 19:07
If you are using an editor like notepad++ you can change the file encoding using the Encoding menu at the top.

Andraax
February 12th, 2019, 19:15
You had some kind of weird encoding on the scripts/gmw.lua file:


$ file gmw1.lua
gmw1.lua: UTF-8 Unicode (with BOM) text, with CRLF line terminators
scripts
$ cat -t gmw.lua
M-oM-;M-?function onInit()^M
Debug.console("here")^M
End
scripts


I stripped that off (and changed "End" to "end") and it works fine.

StoryWeaver
February 12th, 2019, 20:09
I opened it in Visual Studio Code and it must have stripped out the encoding issues.

A good code editor will make your life much easier as well, add in extensions as needed to get keyword highlighting and such things etc.

Wintermute
February 12th, 2019, 20:46
I agree about the code editors. I was using visual studio to create the script that created the file. The VS editor rocks. i can't believe I never thought to check the encoding. Changing it to UTF-8 instead of UTF-8 BOM worked like a charm.

Thanks everyone