BloxxMod
|
  |
| Joined: 28 Nov 2011 |
| Total Posts: 80 |
|
|
| 01 Dec 2011 07:00 PM |
To keep with the tradition, our first program in Lua just prints "Hello World":
print("Hello World") If you are using the stand-alone Lua interpreter, all you have to do to run your first program is to call the interpreter (usually named lua) with the name of the text file that contains your program. For instance, if you write the above program in a file hello.lua, the following command should run it: prompt> lua hello.lua As a slightly more complex example, the following program defines a function to compute the factorial of a given number, asks the user for a number, and prints its factorial:
-- defines a factorial function function fact (n) if n == 0 then return 1 else return n * fact(n-1) end end print("enter a number:") a = io.read("*number") -- read a number print(fact(a)) If you are using Lua embedded in an application, such as CGILua or IUPLua, you may need to refer to the application manual (or to a "local guru") to learn how to run your programs. Nevertheless, Lua is still the same language; most things that we will see here are valid regardless of how you are using Lua. For a start, we recommend that you use the stand-alone interpreter (that is, the lua executable) to run your first examples and experiments. |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 07:02 PM |
Yes, lets start new people off with recursive functions and the io library...
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
BloxxMod
|
  |
| Joined: 28 Nov 2011 |
| Total Posts: 80 |
|
|
| 01 Dec 2011 07:04 PM |
| Are you being serious, or sarcastic... Can't tell over the computer...? |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 07:05 PM |
Completely and utterly sarcastic.
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
BloxxMod
|
  |
| Joined: 28 Nov 2011 |
| Total Posts: 80 |
|
|
| 01 Dec 2011 07:09 PM |
| I don't see why not though, they need to learn. |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 07:09 PM |
| @above what does that mean |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Dec 2011 07:11 PM |
You don't start learning Russian by learning the placement of gerunds and infinitives, do you? You start simple, and work your way to the complex-er stuff, not the other way.
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
BloxxMod
|
  |
| Joined: 28 Nov 2011 |
| Total Posts: 80 |
|
|
| 01 Dec 2011 07:16 PM |
I was always taught hard first oh and if you speak Russian... Я очень не хочу вас поправить, но это заняло у меня одна неделя, чтобы узнать все, что я знаю, в России и в сценарии. Need a translation? |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 07:19 PM |
| Прохладный братан история. Скажи это еще раз. |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 07:20 PM |
That's some nice Google Translate ya got there. And new people aren't going to understand what a recursive function is. You gotta take into consideration the fact that the people reading this have no idea how Lua works and they want to read simple stuff that they can wrap their mind around quickly. If they get confused right away and can't figure this stuff out, then they'll just quit, but if you give them a good starting point with terminology they can understand, then they probably have a lower chance of giving up.
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
| |
|
BloxxMod
|
  |
| Joined: 28 Nov 2011 |
| Total Posts: 80 |
|
|
| 01 Dec 2011 07:25 PM |
1. Reported For Offsite Link 2. Yeah it's just so they can see simple learning, where do you think I learned? There obviously! |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 07:26 PM |
You can post links to the Lua website. And we have the wiki, which is specifically for roblox scripting. Roblox doesn't even allow the io library.
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 07:26 PM |
@^
Yet you copy and past and don't even give credit. |
|
|
| Report Abuse |
|
|
| |
|
BloxxMod
|
  |
| Joined: 28 Nov 2011 |
| Total Posts: 80 |
|
|
| 01 Dec 2011 07:37 PM |
| Credit was given in a previous post |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 07:38 PM |
But not this post.
-~I know what your thinking.~- |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 07:42 PM |
A post made by him before this spam:
"Weak, Making my own lessons for everyone!!!"
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
Grove537
|
  |
| Joined: 05 Feb 2010 |
| Total Posts: 3478 |
|
|
| 01 Dec 2011 07:48 PM |
lol swim, I'm learning Gerunds and infinitives in Language Arts xD
~The greatest free model is your mind~ |
|
|
| Report Abuse |
|
|
xCEMx
|
  |
| Joined: 13 Nov 2011 |
| Total Posts: 47 |
|
|
| 01 Dec 2011 07:55 PM |
@Swim
Oh me? I'm the alt of BloxxMod :)
|
|
|
| Report Abuse |
|
|
Leeav
|
  |
 |
| Joined: 07 Sep 2006 |
| Total Posts: 1905 |
|
|
| 01 Dec 2011 08:46 PM |
| Haha this is straight out of "Programming in Lua" Second Edition, the first page.. I purchased it about a year ago. lol... |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 08:51 PM |
| SwimGuy made a good point. You may take your knowledge of knowing the basics for granted and skipping right ahead, someone with no knowlegde of Lua would of had their head disintigrate. |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 08:51 PM |
@leeav
And I just got banned for posting a link to it :P I thought we could post links to the Lua site...
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 01 Dec 2011 08:52 PM |
| @Leeav, LOL Really? I knew there was something odd about Bloxx's writing. XD |
|
|
| Report Abuse |
|
|