Native Export
ShiVa Editor part
First of all, you have to know that the native export convert all your scripts into C++ files.
C++ being less permissive than the Lua, it is possible your script compile in Lua but not in C++.
The first step is to check errors and warnings for all your scripts and correct if necessary.
In the Game Editor, open your game and choose « Game>Compile ». This action will compile all your scripts.
Image may be NSFW.
Clik here to view.
When the process is done, open the Script Editor and look at the build log if there are warnings or errors.
In my case, I have 2 warnings because I have named some variables with C++ keywords.
For example, I have wrote:
Image may be NSFW.
Clik here to view.
« try » is a C++ keyword. I can replace my code by « local trX, trY » for example.
When all your errors/warnings are corrected, you can now export.
Image may be NSFW.
Clik here to view.
In the Game Editor, choose « Game>Export »:
Image may be NSFW.
Clik here to view.
A window appears: choose your export folder and check « Runtime Package (.stk and .cpp source) ».
Now choose the export profile.
The profile selected, you can click on « Export ».
Image may be NSFW.
Clik here to view.
The export process can be longer than a non native export.
Image may be NSFW.
Clik here to view.
When the export is done, click « OK ».
ShiVa Authoring Tools part
Now open the ShiVa Authoring Tools.
Click on the target platform you are exporting for until the round become green and the screen of the device lights.
Image may be NSFW.
Clik here to view.
In the Application pack, add your game file by browsing your computer using the icon at the right of the field or just drag and drop the file into the field.
Image may be NSFW.
Clik here to view.
You can do the same if you have a startup pack or if you want to use your own icon (in my case, I don’t have any startup pack and use the default icon, fields stay empty).
Now in the right part of your export target, click on « Add » in the Native Code tab to choose the c++ files.
Image may be NSFW.
Clik here to view.
Theses files are located in a folder beside your game, named with the same name plus « _Sources ».
Select all the files in this directory, select a file and press Ctrl+A (select all). Then, click on the « Open » button.
Image may be NSFW.
Clik here to view.
In the Native Code tab, you should see your .cpp and .h files corresponding to your AIModels, functions, states and handlers.
Image may be NSFW.
Clik here to view.
You can now go to the second step of the settings by clicking on the « Step 2: Authoring » button at the top of the window.
Select the Authoring type (NSIS Application in my case) and choose your settings (most of the games can kept default settings).
Image may be NSFW.
Clik here to view.
Go in the step 3 and choose the output folder. If you stay the field empty, the output will be the game directory.
Image may be NSFW.
Clik here to view.
You can now click on the « Build » button at the bottom of the window. A log appears, showing you the build process.
After some seconds/minutes, the process will end. It is possible the build will fail.
Image may be NSFW.
Clik here to view.
I will show you some errors the log report me for my game:
- I can see there is a problem with a variable named « count » in the handler « onKeyboardResetKeyboardMap » of my « InputCore » AIModel.
Image may be NSFW.
Clik here to view.
You can see the variable « count » is declared 2 times:
Image may be NSFW.
Clik here to view.
In lua, you can declare a variable several times, but it’s not the case in c++.
To correct this problem, I just have to replace the second « local count = » by « count = »
- The log report 2 other errors:
Image may be NSFW.
Clik here to view.
These errors refer to 2 functions the compiler has found.
The first function is:
Image may be NSFW.
Clik here to view.
This is a function I have removed and I have forgotten to delete a call to this function.
The second function is a function of the ShiVaScript API:
Image may be NSFW.
Clik here to view.
This is a deprecated function, and the Authoring Tool don’t use deprecated functions. I have to replace it by another function or remove it.
This error can also occurs on an undeclared variable.
- Another error was this one:
Image may be NSFW.
Clik here to view.
In fact, in my script, I have do a search and replace without checking the result and got:
Image may be NSFW.
Clik here to view.
Of course, it must be application.getCurrentUserSceneTaggedObject.
- Don’t forget to fill all parameters when you call a function because your project won’t compile and will return you this error:
Image may be NSFW.
Clik here to view.
In my code, I have wrote:
system.openURL ( “http://www.google.com” )
Instead of (for instance):
system.openURL ( “http://www.google.com”, “_blank” )
When you have corrected all your errors, export again your game with ShiVa Editor (in the Game Editor, choose « Game>Export » and click « Export »).
Then, open the ShiVa Authoring Tools and build the project. The build should end without problems.
Image may be NSFW.
Clik here to view.