Anvil Scripting Reference
  • Getting started
    • Introduction
  • ๐Ÿš€Examples
    • Create a speed overlay
    • Creating a Clock with ImGui
    • Calculating Distances Tool
  • โš™๏ธ User Settings
    • Make use of our settings API
  • ๐Ÿ“ฆNamespaces
    • engine
    • player
    • key
    • mouse
    • memory
    • draw
    • ImGui
  • ๐ŸงชTypes
    • Vec2
    • Vec3
    • Vec4
    • playerState
    • refDef
    • clientEntity
    • cg
    • usercmd
    • trace
    • dvar
  • ๐Ÿ“„Enums
    • CmdButton
    • ImGuiWindowFlags
    • ImGuiStyleVar
    • ImGuiCol
Powered by GitBook
On this page
  • Beginner's Read This
  • Useful Resources
  • Integration
  • Overview
  • Namespaces
  • Types
  • Where to go from here?
  1. Getting started

Introduction

This documentation will show you everything that is needed to get started writing your own Lua Scripts using Anvil.

NextCreate a speed overlay

Last updated 6 months ago

Beginner's Read This

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.

Useful Resources

Integration

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:

print("Hello from Lua")

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:

function sayHello()
    print("Hello from Lua")
end

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:

engine.addEventListener("render", sayHello)

Overview

This section is supposed to give you a quick overview of the existing namespaces and methods.

Namespaces

Types

Where to go from here?

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

here
engine
player
key
mouse
draw
ImGui
Vec2
Vec3
playerState
clientEntity
refdef
cg
usercmd
trace
examples
namespaces
examples
The official Lua Manual
Lua Standard Library
Lua Math Library
Lua Operating System Library
here
Page cover image