This addon is a powerful library/loader. It allows automatically build complex chains of libraries and other packages, no matter what source they are. It can load code from remote sources and control the startup process, supports various binary modules to extend its own features. Contains several useful libraries and actively uses and implements asynchronous code execution.
- Rewrite/replace deflate
- Remove gpm.zip and replace it with deflate
- Improve package info file (links: npm, lua rocks)
- Improve package reloading
- Update promises
- Add version control support
gpm_clear_cache
- Clears the cache of externally downloaded packages.gpm_reload
- Restarts the package manager by refreshing its own code as well as reloading all packages.gpm_list
- Prints a list of loaded packages in the console.
gpm_http_timeout
- Default http timeout for gpm http library.
- Create
package.lua
andinit.lua
files in directorylua/packages/<your-package-name>/
. - Enter information about your package in
package.lua
, below is an example. - Write your code in
init.lua
, if you want the script to be only on the client or server, write in yourpackage.lua
additional linesserver
orclient
, an example below.
Also, you can run an existing addon via gpm, just add the code below to package.lua
, and you don’t even need to add init.lua
.
-- lua/packages/example-package/package.lua
name = "example-package"
version = 000100
-- Files to be used as an entry point into the package, supports relative paths and global relative to "lua/"
init = {
["client"] = "cl_init.lua",
["server"] = "init.lua",
["menu"] = "init.lua"
}
-- If there is no autorun, the package will wait for import from another package
autorun = true
-- Don't touch it if you don't know what you're doing
environment = true
-- Client files ( supports relative paths and global paths by "lua/" )
send = {
"file.lua",
"my_addon/file2.lua"
}
-- If false, the logger will not be created by default and logs color
logger = false
color = Color( 255, 255, 0 )
-- Allowed gamemodes list, if nil then all gamemodes are allowed
gamemodes = {
"sandbox",
"darkrp"
}
-- Allowed maps list, if nil then all maps are allowed
maps = {
"gm_construct"
}
-- If true, then the package is allowed to run only in a singleplayer game
singleplayer = false
-- Enables automatic naming for listed libraries, e.g. all hooks with hook = true will have a package identifier in the hook name, if the hook name is a string of course...
autonames = {
["properties"] = true,
["timer"] = true,
["cvars"] = true,
["hook"] = true,
["net"] = false
}
-
The name of the package is just text that will be displayed in the format
name@version
, for exampleMy Awesome Package@0.0.1
. -
By default, the version is a number whose format is { 00 } { 00 } { 00 } = 0.0.0, you can also use your own version format, just put your version here as a string.
-
This is a universal parameter, which can be either a string or a table, in case it is a string, the package will run on both server and client and menu using the same initialization point, but if it is a table, it must contain parameters like ["realm"] = "path/to/init. lua", if any side is not specified then it won't be launched/sent, i.e. if we specify this value to {["server"] = "init.lua"} the package will only run on server and won't be sent to clients and also will not support menu realm.
init = { ["server"] = "init.lua", ["client"] = "cl_init.lua" }
-
The default setting is
false
, if this parameter is set totrue
and the package is in a validlua/
directory, the package will automatically start and will not wait to be run externally. -
This is the parameter responsible for environment, by default it is
true
, if it is set tofalse
then the package will run in_G
and all global values created in it will go to_G
, as well as you will no longer have access to gpm environment features. I recommend to use this only if you really need it. -
The list of files to send to the client, can be useful if the package runs exclusively on the client and has more than one file. (must be a table with indexes from 1 to infinity)
-
If set to
true
then a personal logger object will be created in the package environment, to easily send logs to the console. If necessary, you can create a logger object yourself, just callgpm.CreateLogger( name, color )
(name
isstring
,color
isColor
).local logger = gpm.Logger logger:Info( "My info message, this supports lua formatting like %s %f and other", "this", 0.025 ) logger:Warn( "Warns!") logger:Error( "Errors!" ) -- by default, they are only sent if the developer convar > 0 logger:Debug( "Debug prings" ) -- you can also set your own condition for debugging information logger:SetDebugFilter( function( str, ... ) return true end )
-
A string with a one gamemode or a list table with allowed gamemodes, if the current gamemode does not match any of the ones listed here the package will not run.
-
A string with a map name or a list table with many map names, if the current map does not match any of the ones listed here the package will not run.
-
The boolean value that allows the package to be executed only in a singleplayer game.
-
This file can also contain any other additional information such as package author, license or description.
Here is an example of the use of import in the init.lua
file of the package.
-- pkg1 init.lua
import "packages/pkg2"
print( package2.feature() )
Look for more examples in our code ;)
For better speed and reliability, the following binary modules can be installed in the game:
In the near future we will release our own, better implemented binary modules to improve performance.
MIT © Pika Software