First Steps
Last updated
Last updated
Now that you’ve covered the essentials, it’s time to start scripting.
Feel free to use any text editor you prefer: , , or even a simple Notepad.
Local scripts are located here: <CS2_Directory>/game/csgo/fatality/scripts
. You may notice there's also a lib
directory, but we’ll get to that later.
Create a new file ending with .lua
, and begin your work on the script.
A typical “Hello world!” example can be a bit trivial, so let’s try something slightly more advanced instead.
Now, let's break down this example script:
With the callback function defined, let’s actually render something on the screen!
This setup allows you not only to draw but also to query information on player health or other entities.
To access the layer, simply reference the surface
field in the draw
table:
After retrieving the layer, you must set a font object before drawing any text on the screen. This is purely for performance reasons, so you don’t have to pass a heavy font object every time you draw text.
With the font set, it’s time to draw some text.
That's it! If you've done everything correctly, you should see something like this:
Most of your scripting will run within we provide. Each event has its own signature, so pay attention to the parameters your callback function should accept. present_queue
doesn’t provide any parameters, so our function doesn’t need any either.
To do this, you first need to access the . We provide a single drawing layer that’s safe to use within the game thread. Due to how the game functions internally, it’s strongly discouraged to call game functions in other threads. Luckily all of our events run in the game thread.
All fonts are stored in . To access a font, either use dot syntax, or treat it like a dictionary:
Invoke the method on the layer. Notice that it’s called using the colon syntax: obj:fn()
, because it’s a method.
Now that you’ve created your first callback, you need to register it so Fatality knows to invoke it. This is done by calling the method on .