Creating a workaround
Learn to code your own workaround
What is a workaround?
A workaround is a system which can be toggled on & off (in the Base
's page menu). Its purpose is mainly to allow users to choose to fix issues & conflicts with external addons. A workaround can be targeted for a specific realm (server, client or both) in order to fix all eventual issues.
All workarounds (except during hot reload) are initialized during the GM:InitPostEntity
hook, assuming that during this time, all fixable hooks should be defined.
Examples
See these two examples from the base:
Setting up the file structure
There are multiple ways of setting up the file structure to define the workarounds:
creating the Lua file in
lua/autorun/
creating the Lua file in
lua/guthscp/base/workarounds/
creating the Lua file in a folder of your module and add it to your
requires
(recommended)
The workaround must be defined as shared (both for server & client)
Defining the workaround
Open your script and start by creating a WORKAROUND
local table which you register as follow:
local WORKAROUND = {}
guthscp.workaround.register( "my_workaround_id", WORKAROUND )
The WORKAROUND
table is what defines your workaround, it will contains properties like the name, the targeted realm & methods that you will define. You also have to specify the identifier of your workaround yourself in the registering function call: choose a unique & recognizable name so it doesn't conflict with any other workarounds.
Now, you should fill the required properties:
local WORKAROUND = {
name = "My Server-Side Workaround",
realm = guthscp.REALMS.SERVER,
}
This is the bare minimum to make a workaround register in the system and to see it in the guthscpbase
menu. Of course, edit them as you'll like.
Adding logic
TODO
Last updated