<?xml version='1.0' encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
              "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
]>
<chapter id="chapter-lua">
	<title>Lua Plugins</title>

	<warning>
		<para>
			You <emphasis role="strong">MUST</emphasis> have the Lua loader
			plugin installed and working as well as the gobject-introspection
			package for GPlugin installed to use Lua plugins.
		</para>
	</warning>

	<simplesect>
		<title>Example Lua Plugin</title>

		<para>
			Like all plugins in GPlugin, Lua plugins must also implement
			the <code>gplugin_query</code>, <code>gplugin_load</code>, and
			<code>gplugin_unload</code> functions.
		</para>

		<para>
			The following is a basic Lua plugin.
		</para>

		<informalexample><programlisting>
		local lgi = require "lgi"
		local GPlugin = lgi.GPlugin

		function gplugin_query()
		    return GPlugin.PluginInfo {
		        id = "gplugin-lua/basic-plugin",
		        abi_version = 0x01020304,
		        name = "basic plugin",
		        category = "test",
		        version = "0.0.10",
		        license_id = "license-id",
		        summary = "basic lua plugin",
		        description = "description of the basic lua plugin",
		        authors = { "Gary Kramlich &lt;grim@reaperworld.com&gt;" },
		        website = "https://keep.imfreedom.org/gplugin/gplugin/"
		    }
		end

		function gplugin_load(plugin)
		    return true
		end

		function gplugin_unload(plugin)
		    return true
		end
		</programlisting></informalexample>
	</simplesect>
</chapter>
