This repo serves as a template for creating large Roblox plugins. That is, plugins so big that they need to be managed with multiple files.
Included is the source folder, containing example files, an example makeplugin.lua file, and a BUILD.md file, containing generalized instructions for building the project.
plugin.lua combines together multiple Lua files (and other files) to make a Roblox plugin.
plugin.lua attempts to run a makefile. This is a file used to determine how the source files will be combined. It also defines extra information about the plugin.
plugin.lua can be run with the following arguments, all of which are optional:
lua plugin.lua [file] [-p]
-
file
Specifies the location of the makefile. If unspecified, then this program attempts to open "makeplugin.lua" in the current directory.
-
-p
Indicates that the program should attempt to automatically output the plugin to Roblox's plugin folder. This involves finding and parsing Roblox's settings file.
In order to make the plugin successfully, folders may need to be created, something which Lua cannot do normally. So, plugin.lua attempts to figure out what type of operating system it's running on, so that it knows how to create folders. It should be able to detect Windows and (hopefully) Unix systems. If plugin.lua cannot figure out what OS it's running on, then the required folders will have to be created manually.
The makefile is run in an environment that has access to the regular global variables, as well as the following variables:
-
META
A table containing information about the plugin. Only one field is absolutely required:
-
META.PLUGIN_NAME
A string indicating the name of the plugin. This value is used as the name of the plugin's folder.
-
-
read ( string path )
Appends the file at path to the current file. Files are appended in the order they are called. path is in relation to the source folder (so "foo.lua" becomes "source/foo.lua").
path may also be a table, in which case, each field in the table is appended as a global variable in a Lua file. Only fields that are valid variable names can be added.
-
write ( string path )
Outputs the current file to path. path is in relation to the plugin folder ("foobar.lua" becomes "build/[PLUGIN_NAME]/foobar.lua").
Also resets the current file, such that
read
may be called once again, to create a different file. -
bwrite ( string path )
Similar to
write
, but files are read and written in binary mode.
Here's an example makefile:
META.PLUGIN_NAME = "Foobar"
META.PLUGIN_VERSION = "1.0"
-- create foolbar.lua
read ( META ) -- append META table
read [[foo.lua]] -- append source/foo.lua
read [[bar.lua]] -- append source/bar.lua
write [[foobar.lua]] -- write to build/Foobar/foobar.lua
-- create icon.png
read [[images/icon.png]] -- append source/images/icon.png
bwrite [[icon.png]] -- write to build/Foobar/icon.png