-
Notifications
You must be signed in to change notification settings - Fork 1
Configuring the game
The file assets/scripts/config.lua
is used by both the engine and gameplay scripts. It is a lua script executed before any other. Here's an example:
-- used by the engine
width = 1920
height = 1200
startScene = 'assets/scripts/arena.lua'
-- custom
bulletSpeed = 30
levelRestartDelay = 2
players = {
{
color = {1, 0, 0},
ai = 'assets/scripts/playerAI_A.lua'
},
{
color = {0, 0, 1},
ai = 'assets/scripts/playerAI_B.lua'
}
}
When launched, the engine will create a 1920x1200 window and start the scene defined by the script assets/scripts/arena.lua
. The full list of names used by the engine can be found below.
Custom scripts may access the configuration values through the global table called Config
:
print(Config.width) -- 1920
print(Config.bulletSpeed) -- 30
print(Config.players[1].ai) -- assets/scripts/playerAI_B.lua
Note that the config script is setting globals, but instead of setting globals, it sets fields in the Config
table. That is intentional. The script is ran in a sandboxed environment instead of the global table. It can still read from the global table, but any attempt to set a global will set a field in the Config
table instead.
Name | Type | Default value | Note |
---|---|---|---|
width |
number | 800 | window width in pixels |
height |
number | 600 | window height in pixels |
fullscreen |
bool | false | make it fullscreen or not |
vsync |
bool | true | use vertical sync or not |
framerateCap |
number | 240 | the maximum number of frames per second |
windowTitle |
string | "Game" | the title of the window |
startScene |
string | nil |
full path to the first scene to load, including the .lua extension |