Another noob bites the dust...

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Doubi
Prole
Posts: 3
Joined: Sun May 19, 2013 2:02 pm

Another noob bites the dust...

Post by Doubi »

Hello everyone ! As I'm totally new to this message board, I will present myself briefly in order to precise my general background and what I'll try to achieve (and it's polite too), before stumping you with all my stupid questions.

I'm a 25 year old guy from France and I'm trained in graphic design and general communication ; I have no prior experience in programming whatsoever, and learning the Lua language and the Löve framework will be my first attempt at that. After a lot of reading on different topics, forums, wiki, etc... I decided to choose the combo Lua/Löve because it seemed really easy to use -even for a complete beginner- and because the community felt great, with lots of help and resources to guide your first steps. The fact that the combo is cross-platform and easy to implement on a Mac Osx without complicated workarounds finished to sell me the stuff.
I must add that I looked quite extensively through the forums to avoid asking already answered questions, but the answers I found weren't too helpful, or maybe weren't clear enough for me. So I'll ask what I need for here, if you don't mind.

I did the first Love tutorials and while it wasn't difficult to do the basic stuff ("Hello World" & basic functions, that I understood), I had the feeling that I was doing something blindly, not knowing the basics of programming or Lua. I really want to truly understand what I'm doing (and not copy pasta things), so I thought I might learn Lua first, to understand the basics of Love. Some useful links have been posted here, but I don't get a number of things:

- I know Love comes with its own version of Lua, but if I want to program Lua outside of Löve (to learn the basics of programming), should I install Lua language (or is it already installed with Löve) ?

- I tried to install the latest version of the Lua language for Mac Osx (I have version 10.8.2) following the directives of the website, but couldn't know if I did it right or wrong. Is there a way to know if I installed it ? Could somebody do a step-by-step instruction on how to install Lua language on a mac ?

- I also tried to install Lua via Rudix (although I didn't really understand what it was) via this website: http://rudamoura.com/luaonmacosx.html : is it the same thing than building it ? Better or worse ? Does it work the same way ?
I followed the instructions and when i typed "lua" in my terminal it seemed that it worked (it printed "hello world" in the terminal).

- I don't really get the "interpreter" thing of Lua: if I installed Lua right, where is this interpreter ? Is it in the terminal, or is it a standalone program ? What is its role exactly ? If I want to code some basic Lua to train myself, have I to use the terminal or another software ? Can I code and run Lua with my text editor (mine is TextWrangler) ? Really could use some basic knowledge on terminal / interpreter (standalone ?) / text editor...

I might have more questions to follow but these are the ones that constantly keep popping up; I know there are a lot of them, so I hope it doesn't bother you as I'm truly lost at this point and need help. I also apologize for any grammatical or other language mistakes as English is not my mother tongue.

THanks in advance !
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Another noob bites the dust...

Post by Davidobot »

Hello and Welcome to the forums! :crazy:
Hope you enjoy your stay here! As for the Lua questions, I have no idea how to use lua alone too, I've heard that you need to use a C compiler with extra modules to use lua on its own.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Another noob bites the dust...

Post by Ref »

If you are on Windows do a search on luaforwindows for a complete package ready to run with an editor.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Another noob bites the dust...

Post by Santos »

Hi!

If you type "lua" in the terminal and it says "Lua <some version> Copyright (C) <some date> Lua.org, PUC-Rio" or something like that, you should be good to go!

The "interpreter" is a command line program, so it's a standalone program, but it is also in the terminal, you can run it from the terminal and it outputs to the terminal, there isn't any GUI. It's role is basically just that I think, getting input from the terminal, outputting to the terminal, reading and writing files, and running other programs. You'd probably want it primarily for experimenting with Lua, but who knows, you might find yourself wanting to do something on your computer and think "hey, I could right a Lua script which can do that!"

So command line Lua can run in "interactive" mode, or it can run a file.

If you type just "lua" into the terminal, you'll be in interactive mode, and you can type and try out stuff, and the interpreter will run whatever you type.

Code: Select all

> a = 100
> print(a)
100
> if a > 50 then
>> print('Yes!')
>> end
Yes!
>
Note that in the interactive interpreter, you can put "=" at the start of a line and it will print what's after it to the terminal, for example...

Code: Select all

> a = 100
> = a * 2
200
>
If you type "lua filename.lua", the interpreter will run "filename.lua" in the current directory, so you can use TextWrangler to write a script, and then run it from the terminal.

So for example, let's say you have a file named "test.lua" in a folder named "luafiles" in your home directory, with has the following text in it:

Code: Select all

print('What is your name?')
name = io.read()
print('Hello, ' .. name .. '!')

Code: Select all

Computer:~ user$ lua luafiles/test.lua
What is your name?
And then you can type your name, and it will greet you! :ultraglee:

Some useful terminal commands are "cd" for "change directory", and "ls", for listing the files in a directory. For example you could do something like this...

Code: Select all

Computer:~ user$ cd luafiles
Computer:~/luafiles user$ ls
test.lua
Computer:~/luafiles user$ lua test.lua
What is your name?
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Another noob bites the dust...

Post by T-Bone »

Since LÖVE comes with Lua built in, you can just use that, I think you'll find it easier. If you open LÖVE from the terminal, output from the "print" will be written in the terminal. So it functions just like a standalone Lua executable.
User avatar
Hexenhammer
Party member
Posts: 175
Joined: Sun Feb 17, 2013 8:19 am

Re: Another noob bites the dust...

Post by Hexenhammer »

Doubi wrote: - I know Love comes with its own version of Lua
It actually doesn't. The official LÖVE downloads are simply linked against the standard Lua interpreter library i.e. the version of Lua in LÖVE is the standard one, not a customized version. LÖVE just adds a lot of functions and gives the program some basic structure using callbacks.
, but if I want to program Lua outside of Löve (to learn the basics of programming)
You can learn the basics of programming within LÖVE. It will be more interesting. The standard Lua interpreter itself only provides the most basic IO. You can read/write files and output messages to the terminal. That's about it. No graphics/GUI, no sound, no mouse..
Personally I learned the basics of programming with QBASIC about 15 years ago. QBASIC was a lot like LÖVE in fact. It was BASIC with all kinds of functions built-in which allowed you to do fun stuff like drawing graphics, playing some sounds etc.
- I tried to install the latest version of the Lua language for Mac Osx (I have version 10.8.2) following the directives of the website, but couldn't know if I did it right or wrong. Is there a way to know if I installed it ? Could somebody do a step-by-step instruction on how to install Lua language on a mac ?
I have never seriously used OS X so I can't really help you there. On Windows the "install process" of the standard Lua interpreter is trivial.. because there is none. You simply copy the Lua executable into your PATH or where your Lua programs are and then you type something like..

Code: Select all

lua5.1 myScript.lua
..at the terminal and the Lua interpreter runs your program (myScript.lua in this case)
- I don't really get the "interpreter" thing of Lua: if I installed Lua right, where is this interpreter ? Is it in the terminal, or is it a standalone program
It is a standalone terminal program :P
I.e. you have to open the terminal and then start the interpreter by typing "lua", "lua5.1" or something like that (depends on your concrete installation).
? What is its role exactly ? I
It executes Lua code. Your write your Lua programs as plain text files, and then feed said text files to the Lua interpreter (e.g. "lua myProgram.lua") and things magically start happening. You can think of the Lua interpreter as a translator between you and the computer. Computers do not understand Lua code, or C code, or Python code for that matter. Thus we need a translator program.
I want to code some basic Lua to train myself, have I to use the terminal or another software ?
As I said, just use LÖVE.
Can I code and run Lua with my text editor (mine is TextWrangler) ?
You can certainly code Lua with your text editor. Lua programs are simple text files. So you can write them with any plain text editor. You cannot run Lua code with a text editor. However, many text editors have a configurable "call program X with the currently open file as an argument" function. You can use this to start Lua programs from your text editor. For example when I press F5 in SciTE (my text editor) it feeds the current file to LÖVE and thus it gets executed by LÖVE i.e. my program runs.
Doubi
Prole
Posts: 3
Joined: Sun May 19, 2013 2:02 pm

Re: Another noob bites the dust...

Post by Doubi »

Why thanks to these warm welcoming messages and all these quick answers ! It's really helpful !
I'll try to answer the answers, but I think I understand a lot better what was unclear to me before...
Santos wrote:If you type "lua" in the terminal and it says "Lua <some version> Copyright (C) <some date> Lua.org, PUC-Rio" or something like that, you should be good to go![/code]
I got this message popping up when I type "lua" in the terminal, so I assume it is finally installed. I tried the examples you gave me and it works just fine; that means I can train myself independently of Love if I want to, great thing. Thanks also for the Terminal knowledge, definitely very useful.

T-Bone wrote:Since LÖVE comes with Lua built in, you can just use that, I think you'll find it easier. If you open LÖVE from the terminal, output from the "print" will be written in the terminal. So it functions just like a standalone Lua executable.
Nice to know it; does that mean that (if I run/open Löve from the terminal) each time there will be a print instruction in the Love file, the print will happen in the terminal instead of in the Love program/window? (if I have print("Hello World"), I'll see "Hello World" in the terminal but not in the Love application that will pop up ?) ? Even for the print graphics functions ? What is the purpose of having parts of your file printed in the terminal/interpreter rather than in another window/app ?

Hexenhammer wrote:You can learn the basics of programming within LÖVE. It will be more interesting. The standard Lua interpreter itself only provides the most basic IO. You can read/write files and output messages to the terminal. That's about it. No graphics/GUI, no sound, no mouse..
Since you're the second one to tell me that, I think I'll try to learn Lua directly within Love. I was just fearing that since Love has specific functions (love.load, etc...) that are in every document, it will confuse me and give me bad habits of programming (ie I could not programm Lua outside of Love).
About the interpreter, thanks for the detailed explanation, I really needed it ! If I understand it well, that interpreter is rather basic and text-only.

One last question though: if I make a more complicated program without Love (not text only, let's say a little application that is supposed to have its own window, like a simple calendar or calculator with a minimal graphic interface), can I code it all in my text editor in Lua language and run it with the interpreter and, If I do so, will it open up in a new/dedicated window or will it stay in the interpreter/terminal ? And can I do it all within the interpreter (or text editor) ?
To sum up, can I make whole complicated programs that could work standalone, only with my text editor and the interpreter, or would I have to have more software/libraries to make them work (as the interpreter seems to be only text) ? It's not my goal to do such a thing for now, I ask this to be sure of the role of every element.

Anyway, great answers from y'all. I already löve this community. Can't wait to make an "OBEY" avatar ! :ultraglee:
LuaWeaver
Party member
Posts: 183
Joined: Wed Mar 02, 2011 11:15 pm
Location: Ohio, USA

Re: Another noob bites the dust...

Post by LuaWeaver »

Hi! Let me see if I can help.
Doubi wrote:...Since you're the second one to tell me that, I think I'll try to learn Lua directly within Love. I was just fearing that since Love has specific functions (love.load, etc...) that are in every document, it will confuse me and give me bad habits of programming (ie I could not programm Lua outside of Love).
About the interpreter, thanks for the detailed explanation, I really needed it ! If I understand it well, that interpreter is rather basic and text-only.
Kind of, the interpreter is what runs any Lua code. Using the interpreter with nothing added is basic and text-only, but LOVE uses the interpreter as well.
Doubi wrote:One last question though: if I make a more complicated program without Love (not text only, let's say a little application that is supposed to have its own window, like a simple calendar or calculator with a minimal graphic interface), can I code it all in my text editor in Lua language and run it with the interpreter and, If I do so, will it open up in a new/dedicated window or will it stay in the interpreter/terminal ? And can I do it all within the interpreter (or text editor) ?
Yes, but you can't do it with ANY images with the standard interpreter. ASCII art FTW?
To use your text editor, save it as "filename.lua". Then, go into your terminal, and use "cd" to get to the proper directory. If you don't know how to do that, you can Google "OS X Shell Tutorial" or something. Just beware - that might be more info than you want.
Doubi wrote:To sum up, can I make whole complicated programs that could work standalone, only with my text editor and the interpreter, or would I have to have more software/libraries to make them work (as the interpreter seems to be only text) ? It's not my goal to do such a thing for now, I ask this to be sure of the role of every element.

Anyway, great answers from y'all. I already löve this community. Can't wait to make an "OBEY" avatar ! :ultraglee:
Again, no images. :(
However, you can do things with text like this:

Code: Select all

  ______
 |     |
_|_____|_ 
|  o o  |
|   >   |
|  \_/  |
 \______/
(this is my first ever ASCII art, it's terrible :death: )

This poorly represents a guy in a hat using just the characters on my keyboard. You can make thin like calculators and whatnot with the magical power of characters like _ and |.

I hope I've answered your questions!
"your actions cause me to infer your ego is the size of three houses" -finley
User avatar
Hexenhammer
Party member
Posts: 175
Joined: Sun Feb 17, 2013 8:19 am

Re: Another noob bites the dust...

Post by Hexenhammer »

Doubi wrote:If I understand it well, that interpreter is rather basic and text-only.
Yes.. unless you add functions to it. Again, LÖVE runs on the Lua interpreter too, but it adds functions for graphics, sound and stuff.
if I make a more complicated program without Love (not text only, let's say a little application that is supposed to have its own window, like a simple calendar or calculator with a minimal graphic interface), can I code it all in my text editor in Lua language and run it with the interpreter
No, because the interpreter itself has no functions for making a GUI. You write all Lua programs (whether terminal, GUI application, or game) as plain text. If you want to make a GUI app you have to add functions to the interpreter though.. or you simply use a package which contains the interpreter already extended with such functions e.g. LÖVE. You could write a graphical calendar application in LÖVE. Your calendar program would still be nothing but a plain text file, the only difference is that you use LÖVE (i.e. the Lua interpreter with extensions) instead of the Lua interpreter alone to execute it.

If you want to transform your plain text source code file(s) into a standalone program (e.g. for distribution - so that your users don't need a LÖVE installation to run it) you simply merge your source code with LÖVE - the result is your program in standalone form. The wiki explains how to do that, it's not complicated.
Doubi
Prole
Posts: 3
Joined: Sun May 19, 2013 2:02 pm

Re: Another noob bites the dust...

Post by Doubi »

Perfectly explained, that's what I wanted to know. I can see clearly now ! I assume you can extend the capabilities of the interpreter by adding libraries (isn't a framework sort of a library ?).

Thanks to both of you ! :awesome:
Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests