Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
20. September 2012

I ran into a small problem today, that took more then a few cycles to puzzle out.


Basically I was installing and configuring Moai to work on Mac, and this process had a few steps.

First I had to install the FMOD libraries and configure them in Xcode. 

Then I needed to build each host ( I am working from Git instead of the compiled binaries )

I then configured my preferred Lua/Moai IDE IntelliJ according to my own guide, which by the way, worked exactly the same.


But then, when it came time to run my code via moai-fmod-ex I got an error along the lines of error ./libfmodex.dylib does not exist which makes sense in the end.  The Moai Mac host is built to expect the FMOD dylib to be in the same directory as executable.  Problem is, when you run it as a tool within IntelliJ and give it a different working directory, it will not find the DLL.  I tried setting the path using DYLD_LIBRARY_PATH, but oddly this didn't work.  I did manage to get the Moai host running by using the bizarrely named install_name_tool, which also presented a new challenge.


Apparently… Xcode used to install this tool in the /usr/bin directory, but then they changed it to the /Developer/usr/bin directory… then apparently they changed it again to the /Applications/ folder, which is not in the PATH and is a pain in the ass to type, so I copied it to /usr/bin ( sudo required).


I then relocated the path to the dylib by:

change to moai fmod host directory

install_name_tool -change './libfmodex.dylb' '/path/to/dylib/file/libfmodex.dylb' moai-fmod-ex



Now it runs properly from within IntelliJ. 


30. August 2012


In celebration of their 40th anniversary, Atari has re-released a number of their classic games as HTML5 in their newly launched web arcade.  Each of the titles has received a facelift, and the list includes:

  • Asteroids
  • Centipede
  • Combat
  • Lunar Lander
  • Missile Command
  • Pong
  • Super Breakout
  • Yar’s Revenge



As you can see, the games have received a facelift:





Yar’s Revenge:





The project is a team up between Atari, CreateJS and Microsoft.  The Microsoft connection is Internet Explorer 10, which allows you to view the arcade ad free.  Atari is releasing an SDK for publishing on their arcade, the download and documentation page is currently down, so details are a bit sparse right now.  Their quick start pdf is currently available and gives a glimpse into the process. Presumably the arcade would work on a revenue sharing scheme, but that is just guesswork at the moment.


The library used to create all the games is called CreateJS, and is a bundling of HTML5 libraries including:

EaselJS – a HTML5 Canvas library with a Flash like API

TweenJS – a chainable tweening library

SoundJS – a HTML5 audio library

PreLoadJS – an asset loading and caching library


Plus the newly added tool, Zoe.  Zoe is a tool that takes SWF Flash animations and generates sprite sheets.



I look forward to looking in to Atari’s new API once their documentation page is back online.  Atari has also created a GitHub repository to support the project, but it is currently a little sparse.  In their own words:


Welcome to the Atari Arcade SDK.

This is the initial release of the SDK, which we hope to evolve over the next few weeks, adding
* more documentation
* examples
* updates

This repository contains
* Atari Arcade SDK classes in scripts/libs
* scripts necessary to run the SDK locally, in scripts/min
* API documentation and a quick start guide in docs/
* A test harness page to bootstrap and launch games



All told, a pretty cool project.  At the very least, check out the arcade, it’s a great deal of fun.



29. August 2012


As the title says, I have inserted a new book into the Unity book list, 3D Games Monetization with Unity and Leadbolt. I do however use the word book in the loosest terms possible, as it is in electronic format only and it weighs in at a mere 37 pages.


That said, it also weights in at a mere 3$, so there is that…


I will admit, before discovering this book, I had never heard of Leadbolt. they are a mobile ad provider in the vein of adMob, but with a world more options than simple banners.



Ads can be added at the application entry point, while running and at the exit point.


I personally HATE ads in mobile games, and gladly pay a premium for an ad free version ( which sadly most developers do not embrace, at least not on Android ), but perhaps ads in a different format will make a difference.


Anyways, if you are a Unity developer and are interested in monetization, you have a new book to check out.


It is my intention to keep the list as comprehensive as possible, so if I have missed a title or you are the author of an upcoming title, please let me know.


25. August 2012


This is a general list of the various resources, books, tutorials and forums available for learning and working with Moai and Lua.  I will keep updating it as I discover more resources.  If I made a mistake or omission, please let me know either in comments or via the Contact form.





Books on Safari




Key websites



22. August 2012


The following is a guide on how to download and configure IntelliJ IDEA for use with MOAI/LUA development.  It is based heavily on information found in this thread, although it goes into a great deal more detail and uses the most recent versions as of 8/22/2012.


First and foremost, go and download IntelliJ IDEA from this link.  Assuming you don’t want to spend money, use the Community Edition version.  I have the full version of WebStorm and sadly, it isn’t fully compatible with the following steps.  Once your download completes, run the installer.


Once installed, run IntelliJ.  Select the menu File->Settings:



On the left hand side, scroll down and locate Plugins, and highlight it:



On the right hand side, locate and click Browse repositories…



In the resulting dialog, in the top right search box enter Lua.  Then locate Lua in the results and double click:



A confirmation dialog should pop up, choose ‘Yes’



In the status bar at the bottom of the window, a download progress bar will appear, wait for it to complete.  Now click OK on the Browse repositories dialog to close it, then Apply in the Settings window.  You will be prompted:



Choose Restart.  Let IntelliJ restart.


Now head over to this thread and download the attached file ( Or use this direct link ).  Save that archive and extract it’s contents somewhere (permanent ).  In my case I used C:\APIs\moai-sdk\IntelliJ which is a sub-directory I created under my MOAI install folder, the actual location doesn’t really matter.


Now in IntelliJ IDEA, create a new Lua project.  Select File->New Project… Check ‘Create project from scratch’, then click Next:




In the bottom left under ‘Select Type’ select Lua Module, then fill in a project name and location.  Click Next:



Kahlua should display as Lau SDK version, click the Finish and your project will be created.


Now on the left hand side in the Project panel, expand External Libraries and right click Kahlua and select ‘Open Library Settings’ ( or hit F4 )



In the resulting Window, under the Classpath tab, click the small ‘+’ icon.




Now navigate to the directory you extracted the archive to earlier and select the directory then click OK.  It should update like this:



Click Apply, then OK to close the Settings window.


You are now setup to do LUA/MOAI development in IntelliJ, but… IT DOESN’T WORK UNTIL YOU RESTART. Alright, done yelling, just figured that point was important.  For some reason, intellisense wont start working until you restart IntelliJ, so do that now.


Now create a new LUA script.  Right click your project in the Project panel, select New->Lua Script:




Call it main.lua and click OK:




Now if you start typing, autocomplete will work:




And Presto!  Don’t worry, all of that work takes perhaps two or three minutes, it just looks like a ton of work because of the level of detail I went into.  Now onto…



Configuring IntelliJ IDEA to run you Moai game


Ok, so this part is completely optional, but will make it easier for you to run a game directly from IntelliJ.  We are going to create a pair of External Tools.  Again, it will look harder than it is.


In IntelliJ, select File->Settings:



On the left hand side, scroll down and locate External Tools and select it:



On the right hand side, locate the + icon and click it:



In the Edit Tool dialog, name it Run Moai, in the group Moai, set the Program: value to point to where you’re MOAI host is, in my case c:\Apis\moai-sdk\bin\win32\moai.exe for parameters set it to $FileName$, which is a macro for the current selected files name; then set Working Directory to $FileDir$, which will expand to the current files directory.  Now click OK.




Click Apply and OK on the External Tools window to close it.


Now you need some code to run.  If you don’t have any code to enter in Main.lau, use the following bare bones application for testing purposes.

MOAISim.openWindow ( "test", 320, 480 )

viewport = ()
viewport:setSize ( 320, 480 )
viewport:setScale ( 320, -480 )
viewport:setOffset ( -1, 1 )

layer = ()
layer:setViewport ( viewport )
MOAISim.pushRenderPass ( layer )


Once you’ve added that code to main.lau, save it, then in the menu select Tools->Moai->Run Moai like so:




If the menu isn’t there, something went wrong with the prior setup, make sure that you clicked Apply after editing.  After you select Run Moai, your application should appear:





After it runs, you will see the results of the console window in IntelliJ’s Run panel, like so:




If it doesn’t, and you have an error like the following:



Make sure that you have your .lua file selected before you choose Run Moai.  Simply click it in the editing window before running.




This setup does however present a bit of a problem… MOAI logs errors out to the standard console while it is running, but IntelliJ will only display the console once running is complete.  This obviously isn’t ideal if you are trying to debug your application or if non-terminal errors are occurring, but don’t worry, there is an easy fix.



Configuring IntelliJ to run Moai in a separate console/terminal window


See, sometimes we want to launch a terminal window that launches our Moai host.  This process is remarkably similar with a minor tweak.


Once again, select File->Settings. Scroll down and select External Tools, on the right hand side select Moai then click the + icon. In the Edit Tool dialog, fill it out as follows:


Name it ‘Run Moai with Command Prompt’, select the Group Moai.

Under program enter cmd.exe

Under Parameters, enter ( obviously adjusting to your Moai install directory ): /c START C:\APIs\moai-sdk\bin\win32\moai.exe $FileDir$\$FileName$

Under working directory, enter: $FileDir$





Then click OK to close the Edit tool window, then Apply then OK to close the Settings window.


Now click inside moai.lua to focus it, then choose the menu Tools->Moai->Run Moai with Command Prompt:





And Voila:



Moai running, with a command prompt receiving output.  I added a print statement to the sample code to generate a bit of output.



There you go, a fully configured IDE for creating and running Moai applications in IntelliJ IDEA with auto complete.  The only downside is, the text completion is not smart enough to figure out dynamic values.  For example, it cannot handle : completions like this:

viewport = ()
viewport:setSize ( 320, 480 )


It will offer auto completion on the first line, but has no idea the members in the second, so if you type viewport: you will get no recommendations.  If you know a way to fix this, please let me know!


Hope that guide proved useful.

Programming General

AppGameKit Studio

See More Tutorials on!

Month List