While Defold allows you to create a lot of your game content using visual tools such as the tilemap and particle effect editors you still create your game logic using a code editor. Game logic is written using the Lua programming language while extensions to the engine itself are written using the native language(s) for the target platform.
Defold uses Lua 5.1 and LuaJIT (depending on target platform) and you need to follow the language specification for those specific versions of Lua when writing your game logic. For more details on how to work with Lua in Defold see our Lua in Defold manual.
Defold allows you to extend the game engine with native code to access platform specific functionality not provided by the engine itself. You can also use native code when the performance of Lua isn’t enough (resource intensive calculations, image processing etc). Refer to our manuals on Native Extensions to learn more.
Defold has a built-in code editor that allows you to open and edit Lua files (.lua), Defold script files (.script, .gui_script and .render_script) as well as any other file with a file extension not natively handled by the editor. Additionally the editor provides syntax highlighting for Lua and script files.
The built-in code editor will show code completion of functions while writing code:
Pressing CTRL + Space will show additional information about functions, arguments and return values:
Defold supports a subset of the Language Server Protocol which can be used to analyse your code and highlight programmatic and stylistic errors, a process also known as linting.
The Lua language server and code linter is available as a plugin. Install the plugin by adding it as a dependency:
https://github.com/defold/lua-language-server/releases/download/v0.0.5/release.zip
Available versions can be seen in the release page for the plugin. Learn more about the plugin on the plugin support page on the Defold forum.
The code editor in Defold provides the basic functionality you need to write code, but for more advanced use cases or for power users with a favorite code editor it is possible to let Defold open files using an external editor. In the Preferences window under the Code tab it is possible to define an external editor that should be used when editing code.
Defold Kit is a Visual Studio Code plugin with the following features:
Learn more and install Defold Kit from the Visual Studio Marketplace.
Community created API reference packages are available for Dash and Zeal.
Did you spot an error or do you have a suggestion? Please let us know on GitHub!
GITHUB