I am using an application (SIMION) that uses Lua as a scripting language, but I am very new to Lua. The SIMION website has lots of help pages and I am stuck on the first code fragment on this page: Code fragment (Method 1 of Loading/Saving an array from a text file).
The code goes as:
-- test.dat:
return {
3, 1, 4,
1, 5, 9
}
-- test.lua:
local array = dofile("test.dat")
-- print contents
for i,v in ipairs(array) do
print(i,v)
end
Now I have a couple of issues with this code: firstly, I get an error when I run this script:
C:\Program Files\Lua\lua54.exe: c:\Users\RD\Documents\Lua-code\array.lua:8: <eof> expected near 'local'
As I am using VScode with the Lue extension it suggests the following fix to the code:
-- test.dat:
do return {
3, 1, 4,
1, 5, 9
} end
With this 'fix' I now get no output (and no errors), so not as I expected from the help pages I referenced earlier in this post.
Could somebody help me with this please? Given that I want to use Lua and SIMION together, I would really appreciate some guidance/pointers on what's going wrong.