The general structure of the code looks like that (omitted implementations for readability)

Code: Select all Reset
-- Some local variables used for statelocal minBrushSizelocal maxBrushSizelocal treeDraftslocal densitylocal roughnesslocal brushSizelocal treeSelection-- Cache drawing functions for performance reasonslocal setTile = Drawing.setTilelocal drawTileFrame = Drawing.drawTileFrame-- Gets the storage table we use for saving/loading the settingslocal function getStorage() end-- Save settings to storagelocal function saveState() end-- Load settings from storagelocal function loadState() end-- Show about dialoglocal function about() end-- Show configuration dialoglocal function configure() end-- True if trees can be placed here in generallocal function isValid(x, y) end-- Initialize stuff, e.g. load settingsfunction script:init() end
Lua editor

Code: Select all Reset
[{"id":"$treeplantertool00_open","type":"tool","preview frames":[{"bmp":"icon.png"}],"title id":"draft_treeplantertool00_title","text id":"draft_treeplantertool00_text","category":"$cat_tree00","script":"#LuaWrapper","meta":{"luawrapper":{"script":"script.lua","dev":true}}}]
JSON checker

You'll find the git repository here: https://github.com/LobbyDivinus/TreePlanterTool
You can use the option "Download ZIP" to download the whole plugin.

Please feel free to create your own tools based on this one. You can also make changes to this tool and make a pull request of the changes on GitHub.

More detailed documentation about the GUI features in Lua can be found in the GUI Compendium