Hi,
I was wondering if there are any plans to integrate Lua with Cocos2D-iPhone? I think it would make a fantastic enhancement.
Rodney
A fast, easy to use, free, and community supported 2D game engine
Hi,
I was wondering if there are any plans to integrate Lua with Cocos2D-iPhone? I think it would make a fantastic enhancement.
Rodney
Would you like to start? ;)
this is something i've been wondering about. i've thought about doing it myself since lua is so nice and easy to work with. plus, i'm making an iphone adventure game engine right now and the scripting would be great. however, it's my understanding that apple forbids the use of interpreted code in iphone apps. i forget the actual wording, but one of the rules says an app cannot download or use scripts that will be interpreted by a virtual machine. lua definitely falls into that category. i'm guessing for security reasons so people can't inject bad script.
has anyone else here used lua and had their app approved by apple? i find it hard to believe that the big guys like EA and Square Enix aren't using an interpreter of some sort, even if it isn't lua. the risk of being rejected is keeping me from using it since i'm an indy developer. i don't want to spend months on a project to have it rejected based on my technology. so for now, i'm just using a nice class hierarchy that allows me to do the game logic in objective c while hiding the CCScene's under workings. it's working nicely, but hardly ideal for people without good programming skills.
it would be so nice to have lua support so i could have my designers not need to know how to use xcode and objective c.
How would they even know you're using scripts if you don't tell them?
they could look in the app bundle and see script files. i'm sure they reserve the right to look into everything they can during approval. unless you encrypted them or something i'm sure they'd see them.
of course they're is the chance they won't notice if you don't tell them. but it's a big risk to spend so long on a project knowing that you technically break the agreement and could be rejected.
I don't have the answer, but doesn't the Playground SDK and Corona SDK support Lua scripting? And of course there is TGB with its Torquescript and Unity with Javascript too? How are games created using these kits getting approved by Apple? What I was thinking was to create wrappers for the Cocos2D methods. I played around with the Corona SDK and it was so nice to prototype my game using its built in Lua scripting. However the SDK was not nearly as complete and robust as Cocos2D at this point.
Rodney
i found an article online about it. it's a little old, back from the iphone sdk launch, so maybe it's not valid anymore. but here is the paragraph about it:
"No interpreted code may be downloaded and used in an Application except for code that is interpreted and run by Apple's Published APIs and builtin interpreter(s)...An Application may not itself install or launch other executable code by any means, including without limitation through the use of a plug-in architecture, calling other frameworks, other APIs or otherwise."
here is the link to the article:
http://news.cnet.com/8301-13739_3-9889159-46.html
the part that says "download and used" i read somewhere was later changed to "downloaded or used" to clear up how that could be interpreted as only disallowing downloaded scripts and not pre packaged ones. i can't find the agreement on the apple site. does anyone else know where it is? i'm probably just overlooking it.
i'm not sure about the other engines and sdks since i've never used any but i do think the big game developers are using their own in house scripting languages and apple is just looking the other way. i think apple has such a random approval process that some get through and some don't. i made a social networking app for a client a while back that was first rejected because of a bug. we fixed the bug and resubmitted the app. the app was then approved without anyone from apple even logging into the system so they obviously didn't even check to see if the bug was fixed. i wish they were more consistent with the process.
i guess i'm just not about to risk the time for nothing. but it would be nice to have scripting.
There is a project called iPhone Wax hosted on google code, which brings support of lua to the iPhone: http://groups.google.com/group/iphonewax
There are a lot of apps in the App Store which use scripting. Therefore, I do not see any reason not to use lua.
I also would like to see lua integration into cocos2d.
I came across this article on the Corona blog where they out some of the apps that are using Lua in the app store. I was interested to see Angry Birds on the list.
http://blog.anscamobile.com/2010/04/lua-the-lingua-franca-of-iphone-games/
Looks like someone has already integrated lua and cocos2d.
http://www.grzmobile.com/blog/2009/12/1/integrating-lua-into-and-iphone-app-part-2.html
wow... I didn't know about it.
regarding the new TOS, how would it affect cocos2d if LUA were integrated ?
The article on the Corona site is arguing that given the people that are already using Lua scripting (EA, Tap Tap, Angry Birds) that Apple couldn't ban it. Personally I wouldn't want to bet the bank on it like Corona are doing, however, I don't see how adding Lua scripting to cocos2d could hurt as long as it was optional and we didn't expose any Apple APIs directly.
I'm interested in what people would want to script. I guess actions would be a likely candidate.
I will share some old experiment (cocos 0.8.2). Its seamless lua - cocos2d bridge. In zip u will find "game" what generates map and logic in lua but use Cocos2d for drawing. I had no intention to share it so its poor documented :) Im sharing it as it is so there might be plenty of bugs :)
Points of interest:
/Cocos-LUA-Bridge/*
/Maps/IMBAMap.lua
riq if you will find something interesting in there feel free to use.
if you will make some modifications give back to community.
Download:
http://ud7.lt/Downloads/MTTD.zip
Implemented API:
* CreateSprite( “name”, parent ) - Creates a new sprite.
* CreateFontString( “name”, parent ) - Creates a new font string.
* CreateTimer( interval, repeats ) - Creates a new font string.
Object
* destroy() - Asks object to cleanup itself
Sprite
* RotateToPoint( x, y, t ) - Rotate object that it would point to x, y.
* StopAllActions() - Removes all actions from the running action list.
* Hide() - Set this object to hidden (it and all of its children will disappear).
* Show() - Set this object to shown (it will appear if its parent is visible).
* MoveTo( x, y, t ) - Move object to x, y with in t seconds.
* EnableMouse(enable) - Set whether this frame will get mouse input.
* StartMoving() - Start moving this frame.
* AddProximityTracking(target, minDistance, maxDistance) - Start tracking proximity between two objects.
* RemoveProximityTracking(target) - Stops tracking proximity between two objects.
* SetAnchorPoint( x, y ) - Set transformations anchor point of object.
* SetPosition( x, y, z ) - Set position of object.
* SetRotation( angle ) - Set object rotation.
* SetAlpha( alpha ) - Set the object's alpha (transparency) value.
* SetColorRGB(r, g, b) - Set to a specific RGB color.
* SetWidth(width) - Set the width of the object.
* SetHeight(height) - Set the height of the object.
* SetScale(x, y) - Sets the X scalar and the Y scalar that the object should scale by.
* GetRotation() - Get rotation of this object.
* GetWidth() - Get the width of this object.
* GetHeight() - Get the height of this object.
* GetTop() - Get the y location of this object.
* GetLeft() - Get the x location of this object.
* GetAlpha() - Return this object's alpha (transparency) value.
* GetParent() - Get parent object;
* GetDistance(target) - Get distance till target.
FontString
* SetText(“text”) - Set the displayed text.
* GetText() - Returns the text currently set for display in the font string
Handlers
* OnTouchBegan( self, x, y ) - Fired then object touched.
* OnTouchEnded( self, x, y ) - Fired then object touch ended.
* OnMoveToFinished( self ) - Fired when MoveTo animation have finished.
* OnRotateFinished( self ) - Fired when RotateToPoint animation have finished.
* OnUpdate( self ) - Fired then timer fires
* OnProximityChange( self, target, distance ) - Fired then AddProximityTracking fires.
Other
* SetAliasing() - Turns on aliasing of Layer
* SetAntiAliasing() - Turns on anti aliasing of Layer
p.s. i have better documented api in docuwiki. anyone have ideas how to export it? :)
actualy all the beauty about my implementation there is no changes in cocos2d :) everything done with categories (if i remember good)
As much as i would love to have Lua working with cocos2d i'm very pessimistic about section 3.3.1. I would wait to see if Corona and others (eg iTorque with TorqueScript) get approved or not after iPhone OS 4 is out.
I think section 3.3.1 does not automatically exclude scripting languages, as long as they don't directly link against the iPhone SDK API. And the intermediate layer issue might be resolved by using byte-compiled lua scripts instead of plain-text. In a way Lua then becomes just static data much like an XML file that is used by an app to do stuff instead of text which is lexically analyzed and compiled at runtime.
The jury is still out. If they decide in favor of Lua count me in, i'd be happy to spend time on an official cocos2d Lua interface!
Does this still fall under 3.3.1 or are we able to use Lua now? Has anyone had anything with Lua rejected?
It's my understanding that Corona compiles lua into native code I could be wrong though.
Apple has relaxed their policy about embedded scripting languages. Excerpt from the dev docs:
"""
In particular, we are relaxing all restrictions on the development tools used to create iOS apps, as long as the resulting apps do not download any code. This should give developers the flexibility they want, while preserving the security we need.
"""
"""
2.7 Apps that download code in any way or form will be rejected
2.8 Apps that install or launch other executable code will be rejected
"""
So if you DO NOT DOWNLOAD scripts from the net you are safe to use Lua. I have used it extensively in my own game (Be2 - Escape from Pongland).
On the other side I do not think that exposing all cocos2d functionalities in lua is that useful: lua is better fitted for small custom logic, configuration stuff or high level calls than for low level graphics, audio, physics, etc.
On the other end, having the lua interpreter already integrated in the cocos2d project with some helpers for bidirectional object/function binding would be REALLY nice!
It's pretty easy to write your game code in Lua with iPhone wax. I wrote a post and put up an example project: http://whatupdave.com/post/2916683437/write-your-cocos2d-game-in-lua
I'm going to write the majority of my next game in Lua, it's so much.. more.. awesomer...
You must log in to post.