[mods] Changes to constants are not visible to user scripts



  • I've been using screepsmod-speedup for a while. It just changes a bunch of constants to make things faster, cheaper, etc. Since the latest update the mod still works, but the updated constants are not visible to user scripts, which is problematic.

    I suspect this is due to IVM. Is this something that needs fixing in the server or do mods need to be updated in some way?

    Thanks.



  • It seems that to update the constants for user scripts in the isolated VM, mods need to do this:

    if (config.engine) {
        config.engine.on('playerSandbox', (sandbox) => {
            sandbox.set('CREEP_SPAWN_TIME', 1);
        });
    }
    

    Note that mods still need to update config.common.constants as before, since that's what the main server engine uses:

    if (config.common) {
        config.common.constants.CREEP_SPAWN_TIME = 1;
    }
    

    I have published screepsmod-fastbuild which implements these changes.

    👍