RogueAustralian
Warlord
- Joined
- Feb 8, 2025
- Messages
- 116
The file *does* need to be imported in your .modinfo:Question on JS and the mod system, perhaps @sukritact might now. I've been trying to create an example mod with a new JS file but it doesn't seem to actually be called.
I add a new JS file and put it under UIScripts in the modinfo file. It does get loaded in the ActionGroup as per Modding.log but nothing in the JS file ever gets called, even if it only consists of a console.log. I've never worked with Web frontend techs so I wouldn't trust myself on the JS front either, but a console.log I can probably manage. Sukritact's UI mod overwrites existing files in their entirety, and I wanted to see if there's ideally a way not do that.
Code:
<ActionGroups>
<ActionGroup id="game-rogues-ui-tweaks-always" scope="game" criteria="always">
<Properties>
<LoadOrder>99</LoadOrder>
</Properties>
<Actions>
<ImportFiles>
<Item>ui/build-queue/model-build-queue.js</Item>
<Item>ui/build-queue/panel-build-queue.js</Item>
<Item>ui/production-chooser/panel-production-chooser.js</Item>
</ImportFiles>
</Actions>
</ActionGroup>
</ActionGroups>
EDIT: I didn't read your message fully. Most JS files at the end have something like this:
JavaScript:
engine.whenReady.then(() => {
const updateModel = () => {
engine.updateWholeModel(BuildQueue);
};
engine.createJSModel('g_BuildQueue', BuildQueue);
BuildQueue.updateCallback = updateModel;
});
This is what registers it with the game. (this is from model-build-queue.js). Another example for panel-build-queue:
JavaScript:
Controls.define('panel-build-queue', {
createInstance: PanelBuildQueue,
description: 'Area for production build queue information.',
styles: ["fs://game/base-standard/ui/build-queue/panel-build-queue.css"]
});
Both of these blocks register it with the game and propagate it to the game. In this case, it's overriding the PanelBuildQueue default with my modded one.
It seems to print to the console log in the debug pane (there's a tab for it that at least prints the errors I catch, so I assume it's acting as stdout, if not only as stderr)IDK where console.log is writing from UI context.
You could try
which write in its own log, Automation.logCode:Automation.log("Hello World !");