-
Notifications
You must be signed in to change notification settings - Fork 0
Modding
Adding mods without verifying their legitimacy can result in unintended side effects! We are not responsible for any damages that may be caused by mods!
0.7 is making MAJOR changes to the modding system, any mod created for 0.6 will not even work a little bit once 0.7 releases.
To install via a URL, a mod author should supply a link to the direct Javascript of this mod. This can be pasted into the "From URL" form on the Add Mod popup accessible via Options.
To install via a file, a mod author should supply a file with the extension .js with the source code of their mod. This can be navigated to in the file explorer menu popup given when clicking the button next to "From File".
Warning: Modding API may change at any time!
The current modding API works almost identically to Cookie Clicker (with a few differences for legal reasons). The start of a mod file should always have the mods.addModData
function called, and its two parameters filled. The first one should be your mod's name. The second parameter will be your mod's entire source code contained within an object. Inside this object should be a function called initialization
. This is all of the code that will be run as soon as the mod is loaded in. You can also create other functions within this object to run inside initialization
. Currently, no system is in place for anything to run in a loop, although this may be changed in a future update to this API. An example of a functioning mod is below:
mods.addModData("test mod",{
initialization:function() {
console.log("mod ran!");
}
});
Your mod can interact with any of the DOM elements, such as adding event listeners. As an example, if you wanted the cookie click to give an additional 1000 cookies you could use the following code:
mods.addModData("test mod",{
initialization:function() {
document.getElementById("cookie").addEventListener("click", () => {
core.cookies += 1000;
});
}
});
There are two options for distributing your mod to other people. The URL Method is the one I recommend for ease of use but it's longer and might not be suitable for some people.
Distributing your mod to others from a URL will require a service to host your file on. Before you get worried, you can actually host your file directly on GitHub by creating a GitHub Pages site and placing your mod file among your site's directory. To get started with a GitHub Pages site, read this documentation article from GitHub.
Once completed, simply place your mod's file among your site's root folder (or whatever folder you choose to build from) and wait for Jekyll to build your site. After this process (usually about a minute), navigate to your JS file in web browser.
Example:
> In your GitHub repo your index.html file is in your root folder (if you have a index.html file) and your mod file is in another folder inside your repo's tree, in this scenario, /mods/mod.js
. In your browser, navigate to this file. It would be under <your username>.github.io/mods/mod.js
. If you see your mod's source code after navigating here, congrats! You have a link to your mod that can be used in-game!
> If this doesn't succeed, this could be because your repo isn't named <your username>.github.io
. It might be named something unique, in which case the link to find your file will be slightly different. In our scenario, it would look something like <your username>.github.io/<your repo name>/mods/mod.js
.
Distributing your mod from a file is simpler to set up, but also has some downsides, mainly being users having to manually update their mod file when you release a new update. To distribute from file, just supply the user with your JS file containing your source code.
Make a new discussion on the show and tell so other people can find your creation!