Open Chorizorro opened 3 years ago
Not most likely, there's no Game.customDraw
or Game.customSave
anymore so that's the source of the error.
Anyone able to fix this?
Anyone able to fix this?
Not that any of us have a fork or write access to this repository, but you just gotta move that stuff over to Game.registerHook('draw', () => {})
Not that any of us have a fork or write access to this repository, but you just gotta move that stuff over to
Game.registerHook('draw', () => {})
So I guess the following workaround will do?
Game.customDraw = {};
Game.customDraw.push = (function(f) {
Game.registerHook('draw', f);
});
Game.customSave = {};
Game.customSave.push = (function(f) {
Game.registerHook('save', f);
});
Edit: I assumed there's a "save" hook the same way there's a "draw" hook but apparently there isn't one, what is Game.customSave
supposed to do?
So I guess the following workaround will do?
Game.customDraw = {}; Game.customDraw.push = (function(f) { Game.registerHook('draw', f); }); Game.customSave = {}; Game.customSave.push = (function(f) { Game.registerHook('save', f); });
Edit: I assumed there's a "save" hook the same way there's a "draw" hook but apparently there isn't one, what is
Game.customSave
supposed to do?
You just gotta send the function to draw hook Game.registerHook('draw', drawCallback)
Game.customSave was probably the old way of saving mod data, before the new API was released last year. It's now included as a property in the object sent to Game.registerMod()
Game.customSave was probably the old way of saving mod data, before the new API was released last year. It's now included as a property in the object sent to
Game.registerMod()
I have no idea how Game.registerMod()
is supposed to be used so I hacked a hook into the game:
// workaround for mod being unmaintained
Game.customDraw = {};
Game.customDraw.push = (function(f) {
Game.registerHook('draw', f);
});
// yeaaah... I know...
Game.customSave = {};
Game.customSave.push = (function(f) {
let old = Game.WriteSave;
Game.WriteSave = (function(...t) {
let r = old(...t);
f();
return r;
});
});
Game.customSave was probably the old way of saving mod data, before the new API was released last year. It's now included as a property in the object sent to
Game.registerMod()
I have no idea how
Game.registerMod()
is supposed to be used so I hacked a hook into the game:// workaround for mod being unmaintained Game.customDraw = {}; Game.customDraw.push = (function(f) { Game.registerHook('draw', f); }); // yeaaah... I know... Game.customSave = {}; Game.customSave.push = (function(f) { let old = Game.WriteSave; Game.WriteSave = (function(t) { old(t); f(); }); });
Yeah, problem: I suck at javascript. Solution:
That's harder than doing it the normal way. Literally just pass the function that was going to the old Game.customDraw
to Game.registerHook
And you also shouldn't rewrite functions like that. This mod's save is already a workaround, so it saves independently from Cookie Clicker. (either left as is or adapted to new API, which isn't that hard)
Port of Darky's Achievement Package to new API.
To top it off, customDraw and customSave literally don't exist anymore, they're useless. The new mod API is the rule now.
That's harder than doing it the normal way. Literally just pass the function that was going to the old Game.customDraw to Game.registerHook
We cannot do that without changing this repo's code and we cannot change the code without the repo's owner doing it for us. What I wrote is a (crappy) workaround to be inserted right before Game.LoadMod('https://acharvak.github.io/Cookie-Clicker-Agronomicon/Agronomicon.js')
.
The new mod API is the rule now.
Admittedly, I could figure out what Game.registerMod
does exactly and see if I can pass it the already existing hooks in a more elegant way than what I just did, but the only API reference I could find is this and it can barely be called an API reference. Suggestions welcome!
We cannot do that without changing this repo's code and we cannot change the code without the repo's owner doing it for us. What I wrote is a (crappy) workaround to be inserted right before
Game.LoadMod('https://acharvak.github.io/Cookie-Clicker-Agronomicon/Agronomicon.js')
.
Anyone can just fork the repo and change the code. I don't think that workaround would do anything, especially since the game doesn't do anything to customSave
or customDraw
. Like, what's even calling the function(f)
? You'd need the original function, at which point using Game.registerHook
would still be easier.
Admittedly, I could figure out what
Game.registerMod
does exactly and see if I can pass it the already existing hooks in a more elegant way than what I just did, but the only API reference I could find is this and it can barely be called an API reference. Suggestions welcome!
Suggestion already sent, I literally ported a mod that's pretty similar to Agronomicon to the new mod API. It has the new way of doing it and you can access the original repo with the old way.
The best modding API docs we have are either the official one found in the game's source code (just search for "registermod") or Dashnet's Discord modding channel.
The add-on throws a Javascript error on load. The add-on seems to still be fully functional, though.
Javascript error in console:
This is most likely caused by
Game.customDraw
not existing: