Package manager supporting isolation, synchronous import, package dependency building and more.
- Package information structure like package.json
- Synchronous import of packages from different sources
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_cache_lifetime
- Packages cache lifetime, in hours, sets after how many hours the downloaded gpm packages will not be relevant.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"
main = "init.lua"
version = 1
-- allowed sides to run package, if client is false then the server will not send anything
client = true
server = true
-- 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
isolation = true
-- client files
send = {
"my/client/file.lua",
"my/client/file2.lua"
}
-- if false, the logger will not be created by default
logger = false
-- if nil, all gamemodes are allowed
gamemodes = {
"sandbox",
"darkrp"
}
-- if nil, all maps are allowed
maps = {
"gm_construct"
}
-- if true, then the package is allowed to run only in a singleplayer game
singleplayer = 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 } { 00 } = 0.0.0, you can also use your own version format, just put your version here as a string.
-
The
main
in this case is the entry point to the package (where the code execution will start from), you can use either the fulllua/
path, for example 'lua/packages/example-package/init.lua' or a local path relative to your package folder. -
An optional parameter that substitutes
main
with another file for the client, helps to easily separate the client and server sides. -
You can change the permissions to run a package, for example if you set
client
tofalse
the client will not be able to run it, moreover it will not even know that such a package exists and therefore will not see its files.menu
is works only in menu realm. -
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 isolation, 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.logger.Create( 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