This is a preliminary document describing Lua library inclusion.
Lua libraries are a collection of lua functions to semplify writing of complex lua code and the reuse of the code.
Lua permit some Object Oriented style (OOP) with some limitation, so it would be better if these functions are organized in Objects (one object for library), attribute and methods.
The method proposed is very simple and must be improved to:
Suggestions and contributing are welcome!
Some libraries in the list at the end of this page, are in an initial development stage, others are just an ideas, and everyone can contribute defining the library interface (i.e.: I like to have a library that do this...with this methods...) or writing the lua code, propose adding methods to existing object and so on.
With the progression of Pipmak development, Could be possible which some libraries were included in Pipmak as native (maybe with different syntax), in that case, library must remain as stub converting old syntax to new and maintaining backward compatibility for old projects which use those libraries.
For the moment, a library file cannot include other library itself,but all library inclusions must be only in main.lua.
Example: if menu.lua require color.lua, You have to include both in main.lua (as described in next paragraph) even if you don't use color.lua alone.
All library files are located in the folder lib under the main folder (which contain main.lua).
If a library require a specific resource (like an image, a sound, ..), these can be put in the folder lib/res.
So, the folder structure is
MyProject.pipmak MyProject.pipmak/main.lua MyProject.pipmak/1/node.lua MyProject.pipmak/2/node.lua MyProject.pipmak/3/node.lua MyProject.pipmak/lib MyProject.pipmak/lib/color.lua MyProject.pipmak/lib/menu.lua MyProject.pipmak/lib/res MyProject.pipmak/lib/res/image1.png MyProject.pipmak/lib/res/image2.png
To include a library in your project, you must add these line to main.lua:
pipmak.dofile("lib/color.lua") pipmak.dofile("lib/dialog.lua")
One line for each library that you want to include.
Wiki: Library_autocubic.lua
Wiki: Library_color.lua
Wiki: Library_dialog.lua
Wiki: Library_menu.lua
Wiki: Library_object3D.lua
Wiki: Main_Page