mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 07:24:52 +09:00
Remove Hotpatch and implement a save patcher in its place. The save patcher takes a normal Factorio save and adds modules to it that's loaded by a generated control.lua file. This greatly reduces the difficulty of adding an existing game to Clusterio and using scenario code in plugins. The mechanism for selecting what code to patch into the saves from plugins is temorary and expected to change with #220.
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
/**
|
|
|
|
Functions frequently needed from different places in the cluster. Ex:
|
|
* Loading Lua scripts
|
|
* Getting an instance's displayname from their ID
|
|
|
|
*/
|
|
|
|
module.exports = ({config} = {}) => ({
|
|
/**
|
|
async function to get Lua from a file, remove comments, minify and return.
|
|
|
|
arg1 is the file path
|
|
arg2 is whether or not to compress the Lua. Makes debugging harder, but reduces bandwidth when many players are online. Recommended for polling commands. Defaults to true.
|
|
Promise resolves with a string of Lua.
|
|
*/
|
|
getLua: require("./getLua.js"),
|
|
/**
|
|
async function to get an instances displayname from their instanceID
|
|
|
|
arg1 is the instanceID
|
|
Promise resolves with a string, either the displayName or instanceID if not found.
|
|
*/
|
|
getInstanceName: require("./getInstanceName.js")(config),
|
|
/**
|
|
async function same as getLua, but using an in memory cache to lower FS operations.
|
|
|
|
arg1 is the file path
|
|
arg2 is whether or not to compress, default true
|
|
Promise resolves with a string of Lua.
|
|
*/
|
|
getCommand: require("./getCommand.js"),
|
|
}) |