Developing
Script initialization
Tip
If your addon does not use global scripts (you are only using scripts attached to entities) you can ignore this section.
AlyxLib uses an embedded version of Scalable Init Support to automatically load your global scripts when the map starts.
If you are not using global scripts (you are only using scripts attached to entities) you can ignore this section.
An initializing template script is created for your addon to quickly get started at the following path: scripts/vscripts/[ADDON NAME]/init.lua
This script is automatically loaded and is the starting point for your code.
It is recommended to use this script to load your other addon scripts instead of using it for actual logic, but this is purely an organizational choice.
Below is an example of what the script would look like when loading addon scripts:
-- This file was automatically generated by alyxlib.
-- alyxlib can only run on server
if IsServer() then
-- Load alyxlib before using it, in case this mod loads before the alyxlib mod.
require("alyxlib.init")
-- execute code or load mod libraries here
require("my_addon_name.main")
require("my_addon_name.debug")
require("my_addon_name.classes")
end
A mod init folder is created with two initializing scripts to work with the Scalable Init Support system:
scripts/vscripts/mods/init/0000000000.luascripts/vscripts/mods/init/[ADDON NAME].lua
The contents of these scripts should generally remain untouched, as they are required by the Scalable Init Support system to automatically load scripts/vscripts/[ADDON NAME]/init.lua at map start.
If you do not want to use your addon folder name as the name for your init script folder you may simply rename it normally and then update the require line in both /mods/init/ scripts.
See Uploading to the workshop on setting up 0000000000.lua.