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
Get GAP : Generic Atlas Packer
GAP : Generic Atlas Packer
gap
Status | In development |
Category | Tool |
Author | _enot |
Tags | atlas, Automation, gap, image, packer, Textures |
More posts
- GAP Update: Bug Fixes! v 0.2.62 days ago
- GAP Update: UTF-8 String Support! v 0.2.59 days ago
- GAP Update: Progress And First Community Feedback!Aug 05, 2024
- GAP: v0.2.3Jul 29, 2024
- GAP Update: Drag and Drop Your Assets!May 27, 2024
- GAP Update: Faster and Smaller Packing!May 20, 2024
- Secrets of custom export. Part 2May 13, 2024
- GAP: v0.1.7 - #8Apr 26, 2024
- GAP: v0.1.6 - #7Apr 22, 2024
Leave a comment
Log in with itch.io to leave a comment.