Construct 2 Plugin
Welcome to mod.io Construct 2 Plugin. It allows game developers to easily control the browsing and installation of mod files in their games. It provides a interface built on the Construct 2 Engine to connect to the mod.io API. We have a test environment available which offers developers a private sandbox to try the Construct 2 Plugin out.
This plugin was created by TetroniMike (Michael Lasch) for Hypnospace Outlaw and has been released open source for other game developers to use in their projects.
Please note that this plugin is only compatible with NW.js exported games on Windows, Mac, and Linux. It might be possible to alter the source code to make it compatible with other export methods, but we will not be going in to how to do so here.
Install the .c2addon files (json_plugin.c2addon and skymen_jszip_v1.4.c2addon) by clicking and dragging them into Construct 2. You will have to close and re-open Construct 2 to finish the installation.
Copy all assets from the provided .capx file's Layout into your game's C2 project, and arrange as you see fit. Add the following plugins to your game:
- Create the following Families, add these objects, and add these 'Family instance variables' with the following default values. These families and variables determine the UI objects' font sizes on the screen relative to window size, and CSS properties:
In the Hypnospace mod.io browser, we've set ModIOMature checkbox object's FontHeightPx to 8 and ExludeCSS to True. Modify as you see fit.
Finally, copy the events into a new Event Sheet.
Change the following variables to match your game's information:
- API (your mod.io API Key)
- GameID (your mod.io game's Game ID)
CompanyName and GameName are used to create a path on the player's computer to store mod files (for example: C:\Users[user name]\CompanyName\GameName\mods). Change the code within 'On start of layout' to change where mod files are stored.
Within the 'ModIO_Download' group, in 'Event sheet 1', there is some disabled code under 'On Zip Loaded' that checks the downloaded zip file for compatibility. For Hypnospace, we have a 'config.ini' file that is required to be either in the root folder or one folder deep in the zip file. This disabled code checks to make sure that it is present and no more than one folder deep. If the config file is at the root of the zip, a folder will be created titled using the mod's mod.io ID number, then the zip unpacked inside it. Feel free to re-enable this code and alter it to check that your game's downloaded mods follow the correct formatting for your game.
Test it and modify as you see fit!
When downloading and installing a mod, the following errors can occur and show the following error codes on the download button:
- Error 001* - config.ini file not found in zip, mod is not formatted properly.
- Error 002* - config.ini file is more than 1 folder deep, mod is not formatted properly
- Error 003 - mod install path either does not exist or could not be created
- Error 004* - weird mod install error (config.ini found in zip but not in resulting unzipped folder contents)
- Error 005 - Error getting download url from mod.io
- Error 999 - Unknown error occured
*These errors only show up if you have enabled the code that checks for mod compatibility. Please change it to match your mod's unique zip file specifications.
Also, if there is an error with the AJAX plugin, which does our GET requests from the mod.io API, the error text will show up in the ModIOText text box.
While this is compatible with Mac and Linux in addition to Windows, we cannot guarantee it will work as expected on those platforms. Please do your own testing as you integrate this project into yours!
Subscriptions, updates, dependencies, and other features are not supported out of the box. You will have to code these yourself, if you want these features.
Our Construct 2 plugin is public and open source. Game developers are welcome to utilize it directly, to add support for mods in their games, or fork it for their games customized use. Want to make changes to our plugin? Submit a pull request with your recommended changes to be reviewed.
- Design is public and open source, the repository can be found here.
- API documentation is public and open source, the repository can be found here.
- Browse engine tools, plugins and wrappers created by the community, or share your own.
- Unreal Engine 4 plugin, easily manage the browsing and install of mods in Unreal Engine 4 games
- Unity Engine plugin, easily manage the browsing and install of mods in Unity Engine games
- Python wrapper, a python wrapper for the mod.io API
- Rust wrapper, rust interface for mod.io
- And more...