This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
The_Awe35's profile picture

Question: What is the point of Lua?

Started by The_Awe35, 25 January 2013 - 08:34 AM
The_Awe35 #1
Posted 25 January 2013 - 09:34 AM
I wasn't sure where I should have put this topic, so if you think I should have put this somewhere else, sorry.
Anyway, I want to know, whats the point of Lua? I know that it can be used to tell if something would work or not before you use it in a program, or maybe to check how much fuel it has, but other than that, I don't see any point to use it. Is there something else to it that i'm missing?
Cranium #2
Posted 25 January 2013 - 09:39 AM
Are you talking about Lua as a whole language and its usefulness? If so, then wow….Lua is used in a lot of ways. Many games are written in Lua, (including parts of WoW) because it is such a small package, and does not require many resources to run. Lua is a great scripting language to learn, because it is simple and easy, with well documented resources.
Doyle3694 #3
Posted 25 January 2013 - 09:43 AM
I think he is talking about lua as the lua interpreter that pops up from writing "lua". And it is useful as fuck. When you start writing real long programs it is really nice to be able to test a couple of functions without a ton of effort.
Orwell #4
Posted 25 January 2013 - 09:45 AM
From what he says, I think he's talking about the Lua prompt. I derive that from this sentence:
I know that it can be used to tell if something would work or not before you use it in a program,

Well, it's mostly to try some lua stuff I guess. But I use it often myself. For example for refueling more than one item ( turtle.refuel(64) ). Or to empty all slots very quickly. ( for i=1,9 do turtle.select(i) turtle.drop(64) end ). Or just to try the exact outcome of some table/string/math operations.

Edit: kinda ninja'd
The_Awe35 #5
Posted 25 January 2013 - 09:46 AM
Okay thats what I was thinking. I did not know that there were games were actually coded with it. thanks though
Orwell #6
Posted 25 January 2013 - 09:48 AM
What Cranium was saying is that Lua is actually the name of the programming language you use to create programs. It also happens to be the name of the program you're talking about (the lua prompt).
NeverCast #7
Posted 25 January 2013 - 09:49 AM
Ever played Garrys Mod? ( I think Half Life 2 might have it in the core also )
All the AI and game mechanics are developed in Lua, on top of the Game Engine which is C++

All the mods and addons? Lua!
There are also entire games that are mostly Lua.. just because Lua is so damn awesome :)/>

And yes, the prompt is used for testing mostly, I personally use it all the time when working on an API.
Bubba #8
Posted 25 January 2013 - 09:52 AM
Okay thats what I was thinking. I did not know that there were games were actually coded with it. thanks though

Eh I would not say that many games are 'coded' in Lua, but rather are extended by it. As a scripting language, Lua is an excellent choice due to its simple syntax and easy implementation. Although there may be a few games created in Lua, it's not really the best choice for doing so.

Edit: By games, I mean three-dimensional and/or graphic intensive games. Text adventures are more than doable in Lua.
Orwell #9
Posted 25 January 2013 - 09:55 AM
My suspicion is that he doesn't really know that Lua is a programming language but rather thinks that it's just the interpreter.
Wired2coffee #10
Posted 25 January 2013 - 02:32 PM
The point of Lua is the equivalent of the point of Minecraft. It really only has a point if you have something to do in mind.
Orwell #11
Posted 25 January 2013 - 03:14 PM
The point of Lua is the equivalent of the point of Minecraft. It really only has a point if you have something to do in mind.
That could be true. But it's clear by now that he meant the program named 'lua' inside CC.
Dlcruz129 #12
Posted 25 January 2013 - 04:14 PM
I find it useful for finding coordinates. When I want to draw a pixel somewhere I call os.pullEvent() and click where I want the pixel to be.
tesla1889 #13
Posted 30 January 2013 - 06:55 PM
–snip–

of the games written (or at least partially written) in lua, the popular ones are:
  • angry birds
  • civilization V
  • crysis
  • fable II
  • far cry
  • garry's mod
  • tom clancy's HAWX
  • painkiller
  • saints row 2
  • serious sam 3
  • sims 2
  • battlefront (1 and 2)
  • warhammer (1 and 2)
  • WoW
source
BigSHinyToys #14
Posted 30 January 2013 - 07:37 PM
lua is also used in scripting events in some GTA games.
Espen #15
Posted 30 January 2013 - 11:41 PM
of the games written (or at least partially written) in lua, the popular ones are:
- snip -
Just a clarification to prevent misunderstanding:
These games weren't written in Lua as that is way beyond Lua's capabilites.
It is rather built on top of these games and might be used e.g. as the preferred choice for scripting.

Take ComputerCraft itself, for example. It wasn't written in Lua, but in Java. Lua is just sitting on top of that and is used to interact with the computer.
billysback #16
Posted 31 January 2013 - 05:11 AM
If you want a game truly made of Lua look at Cobalt
NeverCast #17
Posted 31 January 2013 - 11:41 AM
Was not aware that Cobalt was written in Lua ^_^/>
tesla1889 #18
Posted 31 January 2013 - 01:10 PM
–snip–

if the game is using Lua during runtime to handle events and manipulate data, i count it as being partially written in Lua

ComputerCraft, in fact, is partially written in Lua, although barely

i do not, however, count the use of Lua for user interface as a qualifier for being written in Lua

so basically, if all of the APIs were entirely programmed in Java, CC would not be partially written in Lua
Espen #19
Posted 01 February 2013 - 01:51 AM
–snip–

if the game is using Lua during runtime to handle events and manipulate data, i count it as being partially written in Lua

ComputerCraft, in fact, is partially written in Lua, although barely

i do not, however, count the use of Lua for user interface as a qualifier for being written in Lua
Well the list you're linking to says "Lua-Scripted video games", meaning that they facilitate Lua as their scripting engine.
The games themselves though are most definitely not written in Lua. Just imagine Crysis being written in Lua for a moment.^^

But I get how you meant it. You just wanted to say that Lua is part of the game, which is definitely true.
I just wanted to make a clear distinction between "written in Lua" and "Lua is part of the game", so that someone reading "written in Lua" wouldn't misunderstand and suddenly go around telling people that Crysis was made in Lua. ^_^/>

so basically, if all of the APIs were entirely programmed in Java, CC would not be partially written in Lua
That points to a difference in both of our definitions of what it means when we say something is "written in X".
ComputerCraft was written in Java, because that is Minecraft's language and this is the only way to make a mod for Minecraft.
Lua is then used as the ingame language for ComputerCraft and thus Dan has integrated it into the mod.
All the lua files (bios and api) are just there to make the computer boot up and be used more easily without having every user write his own files first. Pre-Installed vs. Barebones, so to speak.
Another example would be the Redpower computer which is also written in Java.
But this time it didn't use Lua as its ingame language, but FORTH.

So the point I'm trying to make is that the mods themselves are (necessarily) written in Java and that is what I understand when I hear "X is written in Y".
Sure, Lua is part of the mod, as well as FORTH is part of redpower's computer. But these mods were not written in these languages.

Or more to the point:
You say "X was written in Y", but mean "Y is part of X".
But someone who hears "X was written in Y" might just understand "X was written in Y".

Examples to showcase why I wanted to clear up potential misunderstandings:
You say "Crysis was written in Lua" but mean "Lua is part of Crysis".
Someone hears "Crysis was written in lua" and understands "Crysis was written in Lua".

So to sum it up, I'm not saying what you mean is wrong, just that how you said it could be misinterpreted, and that's why I wanted to clear up any potential misunderstanding for other people. Just imagine someone starting to believe Crysis was written in Lua. :lol:/>
Skullblade #20
Posted 01 February 2013 - 12:32 PM
Just imagine Crysis being written in Lua for a moment.^^
telling people that Crysis was made in Lua.
You say "Crysis was written in Lua" but mean "Lua is part of Crysis".
Someone hears "Crysis was written in lua" and understands "Crysis was written in Lua".
Just imagine someone starting to believe Crysis was written in Lua.
Crysis wasn't written in lua?????? :P/>
Espen #21
Posted 01 February 2013 - 01:57 PM
Yeah, in hindsight maybe I should've changed up the examples a little. Ah well, I hope it gets the point across at least. ^_^/>
Skullblade #22
Posted 01 February 2013 - 02:05 PM
Well for the shear fact that you typed that much they should EVENTUALLY get SOMETHING that you were saying :D/>
tesla1889 #23
Posted 03 February 2013 - 06:55 AM
i guess i would have to say that the point of Lua is
  • fast/easy to learn
  • easy data manipulation
  • embeddable in C, C++, or Java
Skullblade #24
Posted 03 February 2013 - 06:57 AM
i guess i would have to say that the point of Lua is
  • fast/easy to learn
  • easy data manipulation
  • embeddable in C, C++, or Java
tesla if you had read the other comments we have deduced that the OP was talking about the PROGRAM lua and what the usefulness was of it.
tesla1889 #25
Posted 03 February 2013 - 10:07 AM
oh. whoops. idk what the point of it is either. i never use it.
Espen #26
Posted 05 February 2013 - 12:49 AM
I find the command "help lua" sums it up nicely:
lua is an interactive prompt for the lua programming language. It's a useful tool for learning the language.

But who am I kidding, almost nobody seems to use "help". Right? ^_^/>