Jump to: navigation, search

Getting a basic plugin to work with LateralGM is fairly simple. Much like any other Java program, you must have a program entry point - the point in the program at which code first starts getting executed. For plugins, this program entry point is the constructor of a class of your choosing. That is to say, when LGM finds your plugin, it will instantiate one of the classes (Which you will specify in the Manifest file), and from there it's up to you what you do. Your plugin must be packaged into a jar (external files are allowed, of course, but LGM will only load the plugin if there is a jar with a manifest and a program entry point). The manifest must have an entry called LGM-Plugin which will point to the class that you wish to be the program entry point.

So in the simplest case, you will have a jar file containing two files: The java-compiled class containing the program entry point, the manifest - usually in a "META-INF" folder - called "MANIFEST.MF" which will contain a line LGM-Plugin: org.helloworld.Hello (along with any other necessary manifest lines), like this:

Manifest-Version: 1.0
LGM-Plugin: org.helloworld.Hello
Class-Path: ../lateralgm.jar

Suppose you'd like to have your plugin also able to be run as a standalone, and suppose that it has a dependency on depends.jar (which we'll place in a HelloDeps folder):

Manifest-Version: 1.0
Main-Class: org.helloworld.Hello
LGM-Plugin: org.helloworld.Hello
Class-Path: ../lateralgm.jar HelloDeps/depends.jar

In this case, we have explained that our program entry point will be located within a folder "org" then under a folder "helloworld" under which a class "Hello" exists, which will look something like this:

public class Hello {
 public Hello() { System.out.println("Hello World"); }

(Don't forget, if you want it to work standalone as well, you must also have a public static void main(String[] args) {} )

This jar will ultimately be placed inside a "plugins" or "Plugins" directory next to LateralGM itself - on the client's computer. Upon loading LGM, right about when the splash screen finishes, the terminal will output "Hello World" from your plugin.

In order to access LGM's variables or other things, you will statically access the class LGM, which contains a number of variables and methods of interest to you, which you can just see by viewing the source code of the LGM class (org/lateralgm/main/

Also of interest, you may register a listener for subframes which will inform you first off, when a subframe (such as the Sprite Frame) is requested, and when the subframe is finished being constructed. This is useful for either providing your own subframe (resource editor), or adding components to the existing subframes. To register a listener, the class of interest is org.lateralgm.subframes.SubframeInformer.SubframeListener; and, of course, its parent class.

You might also want to register a reload listener, which will listen for, primarily, when some event occurs in LGM which would cause most of the interface to change, such as a New Game or Loading a Game. Most importantly, this will also inform if the tree has been repopulated - which is important if your plugin adds additional tree nodes, because you will need to re-add those tree nodes. Note, though, that the menu is not repopulated during a reload, so if you add any menus, you should not need to add them again.

Personal tools