Change to new preprocessor style

This commit is contained in:
Cooldude2606 committed 2024-02-27 23:07:38 +00:00
1 parent ec19d5456e
commit 62abfa903b
37 files changed
+692 -2193

No files matched your search

@@ -1,17 +1,21 @@
import * as lib from "@clusterio/lib";
import { BaseInstancePlugin } from "@clusterio/host";
import { PluginExampleEvent, PluginExampleRequest } from "./messages";// [module] //
import { PluginExampleEvent, PluginExampleRequest } from "./messages";
//%if module
type PuginExampleIPC = {
tick: number,
player_name: string,
};// [] //
};
//%endif
export class InstancePlugin extends BaseInstancePlugin {
async init() {
this.instance.handle(PluginExampleEvent, this.handlePluginExampleEvent.bind(this));
this.instance.handle(PluginExampleRequest, this.handlePluginExampleRequest.bind(this));// [module] //
this.instance.server.handle("ipc-// plugin_name //-plugin_example_ipc", this.handlePluginExampleIPC.bind(this));// [] //
this.instance.handle(PluginExampleRequest, this.handlePluginExampleRequest.bind(this));
//%if module
this.instance.server.handle("ipc-__plugin_name__-plugin_example_ipc", this.handlePluginExampleIPC.bind(this));
//%endif
}
async onInstanceConfigFieldChanged(field: string, curr: unknown, prev: unknown) {
@@ -27,8 +31,10 @@ export class InstancePlugin extends BaseInstancePlugin {
}
async onPlayerEvent(event: lib.PlayerEvent) {
this.logger.info(`onPlayerEvent::onPlayerEvent ${JSON.stringify(event)}`);// [module] //
this.sendRcon("/sc ipc_// plugin_name //.foo()");// [] //
this.logger.info(`onPlayerEvent::onPlayerEvent ${JSON.stringify(event)}`);
//%if module
this.sendRcon("/sc ipc___plugin_name__.foo()");
//%endif
}
async handlePluginExampleEvent(event: PluginExampleEvent) {
@@ -41,9 +47,11 @@ export class InstancePlugin extends BaseInstancePlugin {
myResponseString: request.myString,
myResponseNumbers: request.myNumberArray,
};
}// [module] //
}
//%if module
async handlePluginExampleIPC(event: PuginExampleIPC) {
this.logger.info(JSON.stringify(event));
}// [] //
}
//%endif
}