-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
168 lines (159 loc) · 5.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
"use strict";
const lib = require("@clusterio/lib");
const MigrateInstanceRequest = require("./src/instance_migration/info/MigrateInstanceRequest");
const messages = require("./messages");
const pluginName = "gridworld";
// Define migrate instance permission
require("./src/instance_migration/info/migrateInstancePermission");
lib.definePermission({
name: "gridworld.overview.view",
title: "View gridworld overview",
description: "View gridworld overview",
grantByDefault: true,
});
lib.definePermission({
name: "gridworld.create",
title: "Create gridworld",
description: "Create gridworld",
grantByDefault: true,
});
lib.definePermission({
name: "gridworld.map.refresh",
title: "Refresh map tiles",
description:
"Load tile data from factorio and recreate images for web interface map",
grantByDefault: true,
});
lib.definePermission({
name: "gridworld.map.create_by_exploration",
title: "Create servers by exploration",
description:
"Allow for new instances to be created by exploration through edge_teleports",
grantByDefault: true,
});
lib.definePermission({
name: "gridworld.map.start_by_exploration",
title: "Start servers by exploration",
description:
"Allow for existing instances to be started by exploration through edge_teleports",
grantByDefault: true,
});
lib.definePermission({
name: "gridworld.faction.delete",
title: "Delete faction",
description: "Delete *any* faction",
grantByDefault: false,
});
lib.definePermission({
name: "gridworld.merge.start",
title: "Start merge",
description: "Merge instances to a single map. Resource intensive",
grantByDefault: false,
});
module.exports = {
plugin: {
name: pluginName,
title: "Gridworld",
description: "Generates a gridworld cluster layout",
instanceEntrypoint: "instance",
instanceConfigFields: {
"gridworld.grid_x_position": {
type: "number",
title: "Server position on X axis",
description: "Server position index along the X axis in the gridworld",
initialValue: 1000,
},
"gridworld.grid_y_position": {
type: "number",
title: "Server position on Y axis",
description: "Server position index along the Y axis in the gridworld",
initialValue: 1000,
},
"gridworld.grid_x_size": {
type: "number",
title: "Server size on X axis",
description: "Server size along the X axis",
initialValue: 512,
},
"gridworld.grid_y_size": {
type: "number",
title: "Server size on Y axis",
description: "Server size along the Y axis",
initialValue: 512,
},
"gridworld.is_lobby_server": {
type: "boolean",
title: "Server is a lobby server",
description: "Make this instance act as a lobby server for a gridworld",
initialValue: false,
},
"gridworld.is_grid_square": {
type: "boolean",
title: "Server is a grid square",
description: "Make this instance act as a grid square for a gridworld",
initialValue: false,
},
"gridworld.grid_id": {
type: "number",
title: "Grid ID",
description:
"Grid identifier - used to run multiple gridworlds on the same cluster",
initialValue: 0,
},
"gridworld.grid_name_prefix": {
type: "string",
title: "Grid name prefix",
description: "Prefix for autogeneration, only used for main lobby server where is_lobby_server = true",
initialValue: "",
},
"gridworld.claimed_by_faction": {
type: "string",
title: "Claimed by faction",
description: "Faction that has claimed this server",
initialValue: "",
},
},
controllerEntrypoint: "controller",
controllerConfigFields: {
"gridworld.autosave_interval": {
type: "number",
title: "Autosave Interval",
description: "Interval the gridworld data is autosaved at in seconds.",
initialValue: 600, // 10 minutes
},
"gridworld.gridworld_seed": {
type: "number",
title: "Gridworld seed",
description: "Seed for servers created using gridworld generator",
initialValue: 999,
},
"gridworld.gridworld_map_exchange_string": {
type: "string",
title: "Gridworld map exchange string",
description:
"Map exchange string for servers created using gridworld generator",
initialValue:
// eslint-disable-next-line max-len
">>>eNpjZGBk0GIAgwZ7EOZgSc5PzIHwDjiAMFdyfkFBapFuflEqsjBnclFpSqpufiaq4tS81NxK3aTEYqhiiMkcmUX5eegmsBaX5OehipQUpaYWw5wCwtylRYl5maW5EL0H7OGqGb+qrnZoaJFjAOH/9QwK//+DMJD1AGgjCDMwNoBVMwLFYIA1OSczLY2BQcERiJ1A0owMjNUi69wfVk0BMsFAzwHK+AAVOZAEE/GEMfwccEqpwBgmSOYYg8FnJAbE0hKQ/RBVHA4IBkSyBSTJyNj7duuC78cu2DH+Wfnxkm9Sgj2joavIuw9G6+yAkuwgfzLBiVkzQWAnzCsMMDMf2EOlbtoznj0DAm/sGVlBOkRAhIMFkDjgzczAKMAHZC3oARIKMgwwp9nBjBFxYEwDg28wnzyGMS7bo/sDGBA2IMPlQMQJEAG2EO4yRgjTod+B0UEeJiuJUALUb8SA7IYUhA9Pwqw9jGQ/mkMwIwLZH2giKg5YooELZGEKnHjBDHcNMDwvsMN4DvMdGJlBDJCqL0AxCA8kAzMKQgs4gIObmQEBPtgzuMX47gAAJhSjWw==<<<",
},
"gridworld.tiles_directory": {
type: "string",
title: "Tiles directory",
description: "Folder to store map tiles relative to database",
initialValue: "tiles",
},
},
webEntrypoint: "./web",
routes: [
"/gridworld",
"/gridworld/create",
"/gridworld/factions",
"/gridworld/factions/:factionId/view",
"/gridworld/merge_map",
],
messages: [
MigrateInstanceRequest,
...Object.keys(messages).map(key => messages[key]),
],
},
};