Introduction
This documentation will show you everything that is needed to get started writing your own Lua Scripts using Anvil.
Last updated
This documentation will show you everything that is needed to get started writing your own Lua Scripts using Anvil.
Last updated
If you're completely new to programming, we highly recommend learning the core concepts first.
Variables ( + Datatypes )
Loops
Arrays
Functions
However to give you a mental momentum, there are alot of that you can simply copy into the editor ingame and play with.
Anvil integrates Lua and provides a number of globally available namespaces each with their own set of useful methods. Which namespaces are available is listed .
The Lua tab is pretty straightforward. At the top you have the toolbar where you can:
Open an existing lua file in the editor
Save the current script to a file
Run the current script
Stop the running script
Open this documentation
It is important to understand how the Lua code is being executed. Suppose you have the following piece of Lua code:
If you click on Run Script
at the top of the Lua Tab, this code will be executed exactly once.
This might be no surprise to someone who has some knowledge about programming.
However how would we execute that code every frame of the game?
First lets transform the line of code we have written into a function:
In order to react to certain Events
such as a new frame being rendered, you have to listen for that specific Event
. This concept is commonly called an EventListener.
Anvil on the other hand is referred to as the EventEmitter and will notify you of any events happening right now.
You can react (listen) to certain Events by registering an EventListener
like so:
This section is supposed to give you a quick overview of the existing namespaces and methods.
What this means, is basically: Run the function sayHello
every single frame.
All possible events and other methods that you can call on engine
are described .
We encourage you to take a look at the , to get a feeling how things are done.
For a complete listing of the functions we provide, take a look at the section.
If you wish to provide another example to this documentation you're more than welcome to contact us on out discord server at: Todo