Skip to content

1. Project Setup

Tom O'Sullivan edited this page Nov 2, 2021 · 1 revision

Setting up a project that uses ClassLoader is easy. Firstly, acquire a copy of the appropriate library version for your environment from the Releases Page.

Now you'll want to create a new project, this may vary depending on your usage. For this example imagine we have a folder for our project called hello-world. We now need to create a program entry point file, in plain Lua you might call this main.lua, for Garry's Mod you'll want to create a Lua file with a unique name in the lua/autorun folder.

In our entry point file, we'll include ClassLoader and tell it how to load our classes. To do this, place your copy of class_loader.lua somewhere where you're able to reference from your code. Then edit your entry point file and add the following code:

local ClassLoader = require("{class_loader.lua location}") --Garry's Mod uses "include" instead of "require"

--Tell ClassLoader where our classes are and which one contains our Start() method.
ClassLoader.Bootstrap("{classes folder location}", "your.package.name.StartClass")
Clone this wiki locally