mirror of
https://github.com/asphyxia-core/core.git
synced 2026-12-04 22:49:12 -06:00
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { example, changeName } from './handlers/example';
|
|
|
|
export function register() {
|
|
/* Register game code */
|
|
R.GameCode('NULL');
|
|
|
|
/* A plugin can have multiple contributors. */
|
|
R.Contributor('Your Name', 'http://your-link.com');
|
|
R.Contributor('Others Name');
|
|
|
|
/* Register plugin configuration */
|
|
R.Config('event', {
|
|
type: 'string',
|
|
default: 'EVENT_1',
|
|
options: ['EVENT_1', 'EVENT_2'],
|
|
});
|
|
|
|
/* Register your routes */
|
|
R.Route('example.method', example);
|
|
|
|
/*
|
|
Register a unhandled handler that print all unhandled methods.
|
|
You should remove it before you publish your plugin,
|
|
unless you have specific reason not to.
|
|
*/
|
|
R.Unhandled();
|
|
|
|
/* Insert or clear a existing document in plugin space */
|
|
DB.Upsert({ clicked: { $exists: true } }, { $set: { clicked: 0 } });
|
|
|
|
/* Register a event and increment the click counter */
|
|
R.WebUIEvent('click', async data => {
|
|
console.log('WebUI Button Clicked');
|
|
await DB.Update({ clicked: { $exists: true } }, { $inc: { clicked: 1 } });
|
|
});
|
|
|
|
/* Register a event and increment the click counter */
|
|
R.WebUIEvent('change', changeName);
|
|
|
|
/* Use --dev argument to enable console output. */
|
|
console.log(`Core Version: ${CORE_VERSION}`);
|
|
console.log('Plugin Registered');
|
|
}
|