I've tried to bind a hotkey and am having trouble (spent more time trying to get this to work than I'd like to admit ). There's no error in coherent, and the binding is in the settings menu, the function just doesn't execute. If someone more knowledgeable could look at this and see what's wrong that would be great. I have tried looking at hotbuild2 as an example, everything looks equivalent that I'm aware of. modinfo: Code: ... "live_game": [ "coui://ui/mods/tAutoFactory/tAutoFactory.js", "coui://ui/mods/tAutoFactory/live_game/tAutoFactory.css", "coui://ui/mods/tAutoFactory/live_game/init.js" ], "settings": [ "coui://ui/mods/tAutoFactory/settings/init.js" ], "global_mod_list": [ "coui://ui/mods/tAutoFactory/global_mod_list/tAutoFactory.js" ], ... \ui\mods\tAutoFactory\global_mod_list\tAutoFactory.js: Code: ... (function () { console.log("af global"); action_sets.tAutoFactory = {}; action_sets.tAutoFactory["Manually Execute"] = function(event) { console.log("af hotkey");/*tAutoFactory.manual();*/ }; default_keybinds.tAutoFactory = {}; default_keybinds.tAutoFactory["Manually Execute"] = "q"; })(); ... \ui\mods\tAutoFactory\live_game\init.js: Code: $(function () { ... var tAutoFactoryapplyUIDisplaySettings = model.applyUIDisplaySettings; model.applyUIDisplaySettings = function () { apply_keybinds("tAutoFactory"); tAutoFactoryapplyUIDisplaySettings(); }; ... }); ... Apologies if I don't reply promptly. Might not be here for a few days.
It's not on github, but the wip version is attached the the above post. Thanks for looking, but don't worry too much about trying to fix it. When I get enough time I'll stare it into submission 8)
Nice try, but it didn't work. When I get time I'll start fresh. Make a mod that does the keybind, then add the other stuff to it.
That's great, running model.applyUIDisplaySettings(); just after hijacking it seems to work, is there anything wrong with that? I thought we hijack so it executes at the right time, but if this works then great.
Never mind pamm replaced old **** Yes found out what the error is Code: (function () { "use strict"; function loadTemplate(element, url) { element.load(url, function () { ko.applyBindings(model, element.get(0)); }); } //visible to knockout model.tAutoFactory = tAutoFactory; //update every second setInterval(tAutoFactory.update, 1000); //instead of polling, try hijacking api.select.empty //var tAutoFactory_api_select_empty = api.select.commander; //api.select.commander = function(){ // console.log("hijacked select empty"); // tAutoFactory_api_select_empty(); //}; //hotkey doesn't work, TODO //action_sets.tautofactory["Manually Execute"] = function(event) { console.log("af hotkey");tAutoFactory.manual(); }; //action_sets.tAutoFactory["Manually Execute"] = function(event) { console.log("af hotkey");/*tAutoFactory.manual();*/ }; var tAutoFactoryapplyUIDisplaySettings = model.applyUIDisplaySettings; model.applyUIDisplaySettings = function () { debugger; apply_keybinds("tAutoFactory"); tAutoFactoryapplyUIDisplaySettings(); }; createFloatingFrame('tAutoFactory_frame', 200, 40, {'offset': 'leftCenter', 'left': 0}); loadTemplate($('#tAutoFactory_frame_content'), 'coui://ui/mods/tAutoFactory/live_game/tAutoFactory.html'); })(); This works. $(); is to early and it's not needed cause we are in a big $() anyway Now this was fun
Got it to work. I couldn't remove the jquery from there, because it was needed to load the html at the right time. So I moved the binding to the other js loaded in live_game. Thank you for your help.