Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when using lua filename.lua

I'm very new to lua, and I've been trying to create a lua file using TextWrangler, then execute the file in my terminal (using a Mac). I create the following in a textwrangler file:

for i=1,10 do
  print ("Hello")
    end
  print ("That's all!")

and I save it as test.lua. I then move this file into the lua directory, ~/lua-5.2.3. I then start lua, and use the following command:

lua test.lua

and I get the following error:

stdin: 1: syntax error near 'test'

What am I doing wrong here? I've looked everywhere online for a solution to, what I assume, is a very simple oversight on my part, but I have found nothing. My first thought was that I was putting the file in the wrong place, but I have moved it everywhere with the same result.

like image 881
Jonathan Wells Avatar asked Jan 24 '26 01:01

Jonathan Wells


1 Answers

You can execute script typing lua test.lua in terminal.

If you enter interpreter mode, you can use dofile "test.lua". There is no lua command(function ) there, unless you declare it somewhere.

There is a PIL section about stand-alone interpreter usage and more up-to date reference section.

like image 58
Seagull Avatar answered Jan 26 '26 17:01

Seagull