Difference between revisions of "Making a Plugin"

From GiderosMobile
(Undo revision 12919 by PaulR (talk))
Tag: Undo
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
The Gideros plugin system is used primarily to extend the functionality of the Gideros API, for example by writing a plugin that provides Lua bindings to an existing native library. Although Gideros is open source, the plugin system keeps the size of the core lean and mean by allowing users to choose which plugins to export with which project. Here we'll walk through the process of creating a plugin, hopefully explaining the important bits along the way.
+
===Lua based plugins===
 +
If your plugin is 100% Lua code then you can easily make it into a plugin.
  
To start writing a plugin you need to first get your Gideros native development environment set up, by following [[Special:MyLanguage/Compiling Gideros Source|Compiling Gideros Source]]. You can start off with just the Desktop target, so only really need Qt and Git (and MSYS2 on Windows). But following through the instructions there will allow you to create and build plugins for all Gideros export targets.
+
Just create a folder based on the name of the plugin and add a file (also based on the plugin name) with the extension .gplugin .
  
__TOC__
+
The contents of the file should look like this:
  
===The .gplugin file===
+
<pre>
 +
<plugin name="My plugin name" description="What my plugin does!">
 +
<target name="APK,iOS,Html5,WinRT,Windows,MacOSX,Win32"></target>
 +
</plugin>
 +
</pre>
  
You can see in the gideros/plugins directory that there is a name_of_plugin.gplugin file for each (actually not all, but that's not important just now) plugin. This is an XML file that defines which platforms the plugin supports and what should be done with plugin files when exporting a project to the relevant target. It's important to note that Gideros makes use of template projects for exporting and you can see there are append/by sections which find/replace relevant parts of the template.
+
Also add a sub-folder called 'luaplugin' to your folder, put your Lua files in there. These will be automatically added to a project that adds your plugin. You can run them by using the Lua 'require' command.
  
<source lang="xml">
+
You can test them as userplugins (click add plugin, then click user plugins o find where to add them) then possibly submit them using github to include in the distribution.  If you do submit them for inclusion then please try make the name of the plugin unique to avoid confusion with other similar plugins - eg don't call it UI, but rather give it a name like razorUI ...
<plugin
+
 
  name="Pathfinder"
+
===[[Extend_your_application_with_plugins|Extend your application with plugins]]===
  description="High performance 2D pathfinding."
 
>
 
</source>
 

Revision as of 19:42, 23 December 2019

Lua based plugins

If your plugin is 100% Lua code then you can easily make it into a plugin.

Just create a folder based on the name of the plugin and add a file (also based on the plugin name) with the extension .gplugin .

The contents of the file should look like this:

<plugin name="My plugin name" description="What my plugin does!">
 <target name="APK,iOS,Html5,WinRT,Windows,MacOSX,Win32"></target>
</plugin>

Also add a sub-folder called 'luaplugin' to your folder, put your Lua files in there. These will be automatically added to a project that adds your plugin. You can run them by using the Lua 'require' command.

You can test them as userplugins (click add plugin, then click user plugins o find where to add them) then possibly submit them using github to include in the distribution. If you do submit them for inclusion then please try make the name of the plugin unique to avoid confusion with other similar plugins - eg don't call it UI, but rather give it a name like razorUI ...

Extend your application with plugins