Secrets of custom export. Part 1


Hello everyone!

Today post I want to devote to custom export. I am totally on your side, if you think that every tool should be easy to use. Simpler, better. One button click and all work is done. But it is worth remembering, that flexibility is another key stone of a really good tool.

Our goal is to add as many game engines support as we can. There are already:

  • PixiJS
  • Phaser
  • libGDX
  • PlayCanvas
  • Cocos2d / CocosCreator

On the other hand we do not want to limit GAP usage to predefined list of engines. There are a lot of developers, who work on their own engines. And we want them to use GAP as well, that's why custom export is very important. And today I want to give more detailed information on this topic, to show that it's easy peasy. So, let's begin.

When you download GAP archive you get executable file and modules folder. Modules folder is extremely important. Nothing will work without it. In C++ code we scan this folder to get all possible export options, data we need for UI and lua code itself. If you decided to make own export script, your first step is to add folder inside modules, e. g. modules/my_export. Your second step is to create modules/my_export/export.lua.

In export.lua you need to define export function. This function accepts some data (we will cover it in the next post), uses it somehow and writes data into the file and saves it .  *To be exact data writing is main task of the write function

Let's make small example. If you put this code in newly created file 

  • run GAP
  • choose Custom export (default name, if you have not added unique name)
  • choose path to save
  • add images
  • press Generate button

you'll get your_name.txt file with "Hello world" string. Congratulations! You first custom export script is ready.

Now let's talk a little bit more about write function. As you see there is no body of write function. It is defined in C++ code. This function accepts string as a parameter, prints it into the terminal window, saves it into the vector of strings and then writes all the strings into the file.

If you want to see your game engine name among export options in GAP you need to add couple variables into the script.


MODULE_NAME - name of your engine
EXTENSION - extension of exported data file
DESCRIPTION - extension description to show in Open file dialog

I do not want this post to be long to read, that's why all information about export arguments will reveal into the next one. Hope it was helpful. If you have any questions, waiting for your comments below.

Bye!

Files

GAP_Windows64_v018.zip 1 MB
13 days ago

Get GAP : Generic Atlas Packer

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.