Literally just installed lua, already lost

I have never touched a programming language in my life. This is the first time I have done so, ever.

I’m also probably violating eighty billion rules of the forum. This was the second result in google when I typed “lua forum.” I apologize in advance to the beleagered moderator who has to read these idiotic ramblings.

So now I’m trying to learn lua.

I’m following what appears to be the “Super Simple Guide to Lua for Dumb Stupid Babies:”

https://www.lua.org/pil/1.html

So I run the command print(“Hello World!”)

Awesome, works just fine.

Then it tells me I can make a .lua file, put that in there, and then just type lua filename.lua and it’ll do the same thing.

So I do that. I make print.lua, and then go into lua.exe and type

lua print.lua

and long story short, it doesn’t work. I later find out this is why: when I type lua in, I get:

>lua

nil

So I look up what nil means. nil means lua has no idea what I’m talking about. I get the same response if I type “Banana farts.”

I’m calling lua by _name _and it doesn’t know what that means.

Ok. Cool.

Now, I figure this might be because I’m using lua 5.3, and this Super Simple Dumb Baby Manual is for lua 5.0. After more research, it looks like I’m supposed to call the interpreter. That’s what typing “lua” is supposed to do.

I’ve googled interpreter lua 5.3. interpreter command lua 5.3. interpreter For God’s Sake Someone Help Me I Just Want To Run A File Lua 5.3. None of these work.

I’m just using basic old lua.exe, not CGILua or ABCLua or FBILua or Lua’s Weird Cousin That Visits on Christmas and Hands out Vodka Peanut Brittle.

What am I doing wrong here? Did I mess up the install? Am I supposed to type it 1ua or something? Have I angered God?

Someone help, I’m dumb.

Warmest Regards,

-Some Idiot

Hello @meaculpa103091. Welcome to the Corona Labs forums. We are not a generic Lua support forum. We are here to support Corona SDK (https://coronalabs.com) which uses Lua to build mobile, desktop and TV apps and games. If you’re interested in those things I would suggest you visit our website, download and install Corona SDK. You don’t need your Lua install to use our product, we include our own build. We have a lot of help to get you started.

Now that said, if you’re a) just wanting to learn Lua or b) are going to use it for scripting things for your computer then continuing on your path is a sound one and I would suggest finding a forum that is more oriented towards pure Lua.

For this specific question, to get Lua to run the code in your file you would type on the command line:

lua print.lua

The Lua interpreter would then process the file.

Rob

no like, when I do lua print.lua it doesn’t work at all. It gives an error saying stdin:1: syntax error near ‘print’. So that command doesn’t work at all.

What are you using for a text editor?

Notepad. A friend told me to get Visual Studio so now I’m trying that. But the fundamental problem is that lua isn’t recognizing “lua” as a command.

Like when I type

>lua print.lua

I get “stdin:1: syntax error near ‘print’”

and if I try just typing

>lua

I get “nil”

I suspect, since you show the “>” prompt at the side, that you’re already inside the prompt (from your first bit of code), whereas the book’s examples are speaking about the initial batch of arguments, which are useful for little one-off bits of work.

You could type Control + C (at least, if it’s the same as the interpreter I have up) to jump back out to the Windows prompt and run the command there, or call dofile(“print.lua”) if you’re still inside. (This is basically what the interpreter will do, under the hood.)

Any particular package you installed?

The book is quite good, by the way.

StarCrunch, dofile worked! Thanks so much! Back to my learnin’.

Also, I installed lua 5.3.2 and just followed the instructions from the first thing I could find that read “install lua on windows.” I didn’t do anything fancy, to my knowledge. I had to install something called TDM-GCC to prep it or something.

Did I mention I have no idea what I’m doing? I feel I should stress that.

Hi, thought I’d throw my 10 cents in…

I have always used TextWrangler to edit my Lua code and it works wonderfully. Must be hitting 5 years now. I know there’s better editors with auto-completion for functions and keywords, but this works for me.

Of course, I run my Lua in Corona because it’s the best way to get any visuals and I like Corona a lot.

However, I did just publish a step by step guide on getting Lua working on the command line and running programs with it (for Mac right now, but I will add Windows, which is not hugely different):

http://springboardpillow.blogspot.co.uk/2016/05/get-command-line-lua-working-on-mac-and.html

Hello @meaculpa103091. Welcome to the Corona Labs forums. We are not a generic Lua support forum. We are here to support Corona SDK (https://coronalabs.com) which uses Lua to build mobile, desktop and TV apps and games. If you’re interested in those things I would suggest you visit our website, download and install Corona SDK. You don’t need your Lua install to use our product, we include our own build. We have a lot of help to get you started.

Now that said, if you’re a) just wanting to learn Lua or b) are going to use it for scripting things for your computer then continuing on your path is a sound one and I would suggest finding a forum that is more oriented towards pure Lua.

For this specific question, to get Lua to run the code in your file you would type on the command line:

lua print.lua

The Lua interpreter would then process the file.

Rob

no like, when I do lua print.lua it doesn’t work at all. It gives an error saying stdin:1: syntax error near ‘print’. So that command doesn’t work at all.

What are you using for a text editor?

Notepad. A friend told me to get Visual Studio so now I’m trying that. But the fundamental problem is that lua isn’t recognizing “lua” as a command.

Like when I type

>lua print.lua

I get “stdin:1: syntax error near ‘print’”

and if I try just typing

>lua

I get “nil”

I suspect, since you show the “>” prompt at the side, that you’re already inside the prompt (from your first bit of code), whereas the book’s examples are speaking about the initial batch of arguments, which are useful for little one-off bits of work.

You could type Control + C (at least, if it’s the same as the interpreter I have up) to jump back out to the Windows prompt and run the command there, or call dofile(“print.lua”) if you’re still inside. (This is basically what the interpreter will do, under the hood.)

Any particular package you installed?

The book is quite good, by the way.

StarCrunch, dofile worked! Thanks so much! Back to my learnin’.

Also, I installed lua 5.3.2 and just followed the instructions from the first thing I could find that read “install lua on windows.” I didn’t do anything fancy, to my knowledge. I had to install something called TDM-GCC to prep it or something.

Did I mention I have no idea what I’m doing? I feel I should stress that.

Hi, thought I’d throw my 10 cents in…

I have always used TextWrangler to edit my Lua code and it works wonderfully. Must be hitting 5 years now. I know there’s better editors with auto-completion for functions and keywords, but this works for me.

Of course, I run my Lua in Corona because it’s the best way to get any visuals and I like Corona a lot.

However, I did just publish a step by step guide on getting Lua working on the command line and running programs with it (for Mac right now, but I will add Windows, which is not hugely different):

http://springboardpillow.blogspot.co.uk/2016/05/get-command-line-lua-working-on-mac-and.html