Extending Editor API

If we have a set of operations that we would like to add to the core editor API, then we can create a new file in the editor root folder, named properly. The layout of the file will need to follow this pattern (example some decal editing API):


After we have written this file, we need to add it to the main editor initialize function. For this, open for edit the /lua/ge/editor/main.lua and add the proper lines in the initialize function:

Adding a Module Example
-- this will create a table instance with your module
M.mySpecialModule = require("editor/myspecial")

-- this will call the module's initialize function with
-- the M argument which is the actual editor table

So, from now on your functions can be called from anywhere, as editor.selectDecalTemplate(…..)

The core logic of the tools are kept as these modules, no GUI code inside them, just pure operations over the data. The tools GUI found in the editor/extensions are using the various APIs found in these modules to operate over the game data.