mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 15:33:12 +09:00
Add clusterio module with API for lua code
Add a shared API for lua code through a module named clusterio.
This commit is contained in:
1 parent
221dc855f4
commit
66aa7e1e43
9 files changed
+139
-43
No files matched your search
@@ -11,6 +11,7 @@ const link = require("lib/link");
|
||||
const plugin = require("lib/plugin");
|
||||
const errors = require("lib/errors");
|
||||
const prometheus = require('lib/prometheus');
|
||||
const luaTools = require('lib/luaTools');
|
||||
|
||||
|
||||
/**
|
||||
@@ -175,7 +176,7 @@ class Instance extends link.Link{
|
||||
|
||||
module = Object.assign({
|
||||
version: plugin.info.version,
|
||||
dependencies: {},
|
||||
dependencies: { 'clusterio': '*' },
|
||||
path: modulePath,
|
||||
load: [],
|
||||
require: [],
|
||||
@@ -203,7 +204,7 @@ class Instance extends link.Link{
|
||||
|
||||
module = Object.assign({
|
||||
path: path.join('modules', entry.name),
|
||||
dependencies: {},
|
||||
dependencies: { 'clusterio': '*' },
|
||||
load: [],
|
||||
require: [],
|
||||
}, module);
|
||||
@@ -218,12 +219,22 @@ class Instance extends link.Link{
|
||||
});
|
||||
|
||||
await this.server.start(saveName);
|
||||
await this.server.disableAchievements()
|
||||
await this.updateInstanceData();
|
||||
|
||||
for (let pluginInstance of this.plugins.values()) {
|
||||
await pluginInstance.onStart();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update instance information on the Factorio side
|
||||
*/
|
||||
async updateInstanceData() {
|
||||
let name = luaTools.escapeString(this.config.name);
|
||||
await this.server.sendRcon(`/sc clusterio_private.update_instance(${this.config.id}, "${name}")`, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the instance
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user