Good practice¶
The contents of this page are not strict guidelines, but rather are recommendations for how to make plugins. If you have a very good reason to go against some of this advice, then you can. Some of these recommendations are to benefit you as developers in keeping track of your plugin's progress, some will benefit users of your plugins in understanding how to use it, and some will reduce friction in passing the plugin through the moderation process.
Duplicate plugins¶
Try not make a plugin that does pretty much the same as another plugin.
- We get that people want to play around and make plugins their own way, but it isn't very helpful if there are already 17 different plugins for checking best-in-slot equipment, and you want to make #18. If there are significant overlaps between your plugin and an existing plugin, it is recommended that you do one of:
- Ask for your features to be added to the existing plugin
- Contact the existing plugin creator and ask to collaborate
- Make your plugin in a way that it uses the existing plugin as a dependency, so your plugin only includes the new bits
This ensures that the plugin hub does not get bloated with duplicate plugins, making both moderation and plugin discovery more streamlined. Duplicate plugins are not disallowed, but if your plugin does not have any major improvements over an existing plugin then it will be a lower priority for moderation.
Keep your code clean¶
- The files that you submit to mod.io for review and moderation will be the same files that end up being downloaded by users of your plugin.
- Your code should be easy for a moderator to read and review, so leave in the comments and make sure you have sensible variable and function names.
- Exclude any files you might have in your development directory that aren't necessary for the plugin to run, such as .git , .gitignore , .luarc.json , or README.md
Dependency support¶
If your plugin allows dependants, you need to plan for long term support and backwards compatibility.
- This doesn't necessarily mean committing to you maintaining the plugin forever, but rather that any new versions of your plugin should be released in a way that will not break any dependants.
- For example, if you want to change how a function works, or what inputs it takes, then the new version of that plugin needs to still work with inputs specified in the old way.
- Lua inherently supports variable numbers of arguments to function calls, so any new arguments automatically receive a value of "nil" if they are unspecified This is useful for making functions backward-compatible.
- It may be better to make a new version of the function, and keep both functions present in the new version of the plugin. Label the old version as "do not use", and only once you are sure that all dependent plugins have transitioned would the old function be removed.
Collaboration¶
If your plugin intends to have any degree of collaboration, it is recommended to set up a GitHub (or similar) project to allow people to get direct access to your plugin's code.
- If you intend to have multiple people contributing, this will keep everyone up to date.
- If your plugin has dependencies, it allows the maintainers of those dependencies to test how their changes will affect your plugin.
- If your plugin is a dependant to other plugins, it allows you to share updates to your plugin with those developers for them to ensure those plugins still function.
Version numbers¶
Version numbers help anyone testing or using your plugin know exactly which code they are using. A good system is semantic versioning which uses three parts: MAJOR.MINOR.PATCH.
MAJORversion when you make massive changesMINORversion when you add functionalityPATCHversion when you make bug fixes
For example, a plugin might be on version 1.5.3. If you fix some typos, that would become 1.5.4. If you add in a new set of options and controls, that would become 1.6.0. If you overhaul the plugin to use a different structure and flow, then it would become 2.0.0. Each number can be multiple digits, such as if you made 9 more typos as separate patches then it would become 1.5.13.
When submitting a file to mod.io, you should include the version number in the file name so that it is easy to read at a glance, e.g. my-plugin-1-5-3.zip.
Console logging¶
Be sensible with how much you send log() or print() message to the console.
- During development and for bugfixing, it is helpful to send a lot of messages to the console to track everything that your plugin is doing, to identify inconsistencies and track errors.
- Once deployed, it would be confusing if every plugin sent lots of messages, so it is helpful to reduce the number of messages sent when you package up your plugin into a zip file for submission.
- If you want to include lots of logging then it should be toggleable, and off by default.
Localisation¶
Language localisation, also known as translation, is the process of making a plugin display its text in the same language as the RuneScape client. This is completely optional, but if you do choose to implement localisation then it will need to be checked by someone from the Jagex localisation team. For this reason, we request that you implement it as follows:
- Store all of your different text strings in a table structure in separate files for each language, e.g.
en.lua,fr.lua,de.lua, andpt.lua. - Load the appropriate file for the language chosen, this can be obtained automatically from
game.options.Language.settingif you so choose. - Wherever you want to display a localised text string, refer to a field in the loaded language file.
This approach allows for easy moderation of your localisation, while minimising how much it disrupts the code to swap strings in and out.
Defining ID numbers¶
In your plugin, you may wish to store the ID number of an NPC, Obj, Loc, UI element, or anything else. Whilst you can do this by writing the number and storing it in a variable, it is better to do so by writing the entity's name in the id structure. For example:
Example
The first example is just a number that doesn't mean anything by itself, it requires a comment to explain itself, and if there is a typo in the number then it will not be caught because the wrong number will still likely correspond to a real Sound ID.
In contrast, the second example is easy to see what it refers to without any commenting, includes the type of thing it is an ID for, and the name cannot have a typo without causing an error during development that is easy to catch.