★ TouchArcade needs your help. Click here to support us on Patreon.

Lua / Corona?

12-08-2009, 02:35 PM
#1
Joined: Mar 2009
Location: Oslo, Norway
Posts: 731
Lua / Corona?

Posted this over at macrumors as well, but maybe I'll have better luck here?

Hi, there. I've recently become aware of the above mentioned language and SDK but fail to see the benefits the developers are claiming. Is their claim regarding speed of development simply down to the syntax of Lua or is there any bigger benefits?

Has anyone here tried Corona? If so, can it be combined with objective-C code? Thanking you all in advance for any feedback.
12-08-2009, 03:47 PM
#2
Quote:
Originally Posted by NickFalk View Post
Posted this over at macrumors as well, but maybe I'll have better luck here?

Hi, there. I've recently become aware of the above mentioned language and SDK but fail to see the benefits the developers are claiming. Is their claim regarding speed of development simply down to the syntax of Lua or is there any bigger benefits?

Has anyone here tried Corona? If so, can it be combined with objective-C code? Thanking you all in advance for any feedback.
I don't know anything about Corona, however I know a LOT about Lua. My game, Flickitty is basically written in Lua with over 26,000+ lines of Lua Code.

What benefits are you talking about?

Lua runs extremely fast on mobile hardware. In fact, we get about 60 FPS on 2nd Gen iPod Touch, which puts it at among the fastest running Platformers/Ragdoll/Physics games out there.

Lua has a very small footprint, also making it great for mobile hardware.

Lua is very flexible, with hundreds of mods available and easy linking to different libraries.

Lua allows quick prototyping- just like any scripted language, Lua does not require compiling so minor changes can be made very quickly and tested. This is the biggest benefit that we saw with Flickitty- I was able to test hundreds of control schemes in a matter of days (not weeks).

Lua is Object Oriented, which allows you to apply a single script to an object and let it run on its own. Flickitty has hundreds of objects in-game, all running simultaneously with full physics. Each object has its own script.

Lua has a very simple sytax, without redundancies nor bloat. You don't have 300 different ways to manipulate a string. Porting code from ActionScript to Lua is pretty easy, even though the languages are not similar in syntax.

Lua is used in World of Warcraft, among thousands of other projects.

Lua does have a few things that may take a bit to get used to. Arrays start at 1, not 0. Actually, there isn't a such thing as an array, they are in fact tables, but you can insert/push data into the table like an Array. Lua also makes all variable GLOBAL by default, unless you explicitly declare them LOCAL.

A ragdoll physics platformer:Flickitty
The artist: randall schleufer
Twitter: @FlickittyiPhone

Last edited by Flickitty; 12-08-2009 at 04:41 PM.

12-08-2009, 11:00 PM
#3
Joined: Sep 2009
Location: Brampton, Ontario
Posts: 344
Hey Flickitty, do you have any links or anything that describe how get set up with Lua for doing development? You don't use Corona, do you? I'm just curious about your workflow.
12-08-2009, 11:43 PM
#4
Quote:
Originally Posted by ElectricGrandpa View Post
Hey Flickitty, do you have any links or anything that describe how get set up with Lua for doing development? You don't use Corona, do you? I'm just curious about your workflow.
No, we don't use Corona. I had never heard of it until this thread.

I haven't checked the official Lua Site for a while, but they might have some information there: http://www.lua.org/

As far as workflow goes, do you mean maintaining the two seperate code environments while maintaining documentation/bug reports and testing?

A ragdoll physics platformer:Flickitty
The artist: randall schleufer
Twitter: @FlickittyiPhone
12-09-2009, 01:02 AM
#5
Joined: Oct 2009
Posts: 241
Send a message via MSN to tukun
or you can have a look at Squirrel scripting language. I use it at work n its awesome, very similar to Lua
12-09-2009, 02:27 AM
#6
Joined: Sep 2009
Location: Brampton, Ontario
Posts: 344
Yeah I guess I'm just wondering what IDE you write the code in. It seems like an interesting approach... I assume it doesn't go against Apple's "no runtime scripting" policy because you can actually compile lua, is that right?

Last edited by ElectricGrandpa; 12-09-2009 at 02:40 AM.
12-09-2009, 03:17 AM
#7
Joined: Mar 2009
Location: Oslo, Norway
Posts: 731
Quote:
Originally Posted by Flickitty View Post
No, we don't use Corona. I had never heard of it until this thread.
Strangely befitting as I hadn't heard of Lua at all until you mentioned it in another thread. It was googling Lua + iPhone that made me aware of Corona. I guess you must use yor own custom-code then?
12-09-2009, 03:22 AM
#8
Quote:
Originally Posted by ElectricGrandpa View Post
Yeah I guess I'm just wondering what IDE you write the code in. It seems like an interesting approach... I assume it doesn't go against Apple's "no runtime scripting" policy because you can actually compile lua, is that right?
Apples runtime scripting policy is widely misunderstood. For the most part, what they DON'T want is an interpreter that downloads scripts- they want strict control over the code on the device. This is one reason why Flash isn't available in Safari (or elsewhere).

Lua isn't compiled, nor is it hidden when we submit. The extention on the files are very plainly *.lua and there are several dozen of them. We do encrypt the files in order to prevent tampering.

My workflow is wildly unexciting. I use Crimson Editor, upload the files directly to my Jailbroken phone using iPhoneBrowser, and archive my work manually. My code is fairly well documented, and I don't keep bug reports.

However, since the 1.05 update was so massive, I kept a log of changes and bugs, and stepped through the list one item at a time until it was done.

Dan East coded the game engine with about 99% C/C++. He uses Windows for this (Visual Studio?) and only links the necessary components for MacOS. Of course he uses a Mac to build Release and Distribution builds.

Dan sends the Windows and iPhone builds to me for testing. I send content, including the Lua script, back to Dan so that he can fix bugs/debug or whatever based on my needs or analysis.

Our two environments are completely separate.

The game engine provides only the very basic functionality. To give you an idea of how flexible this is, our 1.05 update required only Lua to program. A small internal bug fix was done on the engine. This is my list of additions to 1.05 via Lua:

* Mini Game- Snowball Challenge
* In-Game Map Editor
* Holiday Elite Hat
* Elite Hats now have map/player modifiers
* Breakable Tiles
* Keys and Locked Tiles
* Coin Collecting
* Vending Machine (dispenses map/player modifiers)
* Weather Effects
* New Items and Objects

As it is now, I could write a different game written entirely in Lua. It could be an RTS, RPG, Isometric, Top-Down, Puzzler, Touch Adventure, Classic Platformer... pretty much anything except 3D. Our 3D components were removed since they weren't needed.

Wow, that was long-winded.

A ragdoll physics platformer:Flickitty
The artist: randall schleufer
Twitter: @FlickittyiPhone
12-09-2009, 06:25 AM
#9
Joined: Nov 2008
Location: Baltimore
Posts: 205
1. Mouse House 1 and 2 and BANG engine are about 20K lines of Lua also.

Games run as MODS for the core engine all games are written in Lua and the engine runs on 5 platforms from iPhone, Wii, Mac, Win, Linux

2. SOI2 free engine uses Lua

3. http://www.stonetrip.com/
Is a Lua based game IDE... works on iphone... windows only tho :P

4. Apple changed the license to read that non scripts would be run.
They took out the down load and run wording.

5. That being said many many games in the app store use Lua.
A number of the best selling games ever on the phone in fact.
No I won't list them.

Anyhow over the last year I have never heard of any app being rejected for usiung Lua or any scripting language.

The only app Im aware of that was rejected was teh C64 emulator... and that was only after someone hacked it and found a way to load and run their own script or get to a command line like shell.
This was later fixed.

6. The best over view of Lua and what it looks like and what it can do is actually the wikipedia article and not the main site.

http://en.wikipedia.org/wiki/Lua_(programming_language)

7. Squirrel is a neat scripting language inspired by lua but with C /C++ style
syntax, stricter syntax and some interesting and somewhat useful additions like highly controlled GC.

I believe squirrel actually used parts of lua's runtime internally for tables etc. Tho Im not sure if the code was used or just the design.

8. Lua has a much bigger community then Squirrel, Better support etc
hundreds of add ons... I find Squirrel tempting but the trade offs vs the very active Lua community might not be worth it.

/me stops babbling