@expcluster/legacy 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/browser/package.json +40 -0
  3. package/dist/browser/tsconfig.browser.tsbuildinfo +1 -0
  4. package/dist/browser/web/index.d.ts +1 -0
  5. package/dist/browser/web/index.d.ts.map +1 -0
  6. package/dist/browser/web/index.js +2 -0
  7. package/dist/browser/web/index.js.map +1 -0
  8. package/dist/node/index.d.ts +3 -0
  9. package/dist/node/index.d.ts.map +1 -0
  10. package/dist/node/index.js +10 -0
  11. package/dist/node/index.js.map +1 -0
  12. package/dist/node/instance.d.ts +4 -0
  13. package/dist/node/instance.d.ts.map +1 -0
  14. package/dist/node/instance.js +8 -0
  15. package/dist/node/instance.js.map +1 -0
  16. package/dist/node/tsconfig.node.tsbuildinfo +1 -0
  17. package/dist/web/manifest.json +7 -0
  18. package/dist/web/static/exp_legacy.9b6538559ed5e689539c.js +355 -0
  19. package/dist/web/static/index_ts.8f9d451c8d3f7f293da6.js +22 -0
  20. package/dist/web/static/main.94e1b48804112ca8bdfc.js +118 -0
  21. package/dist/web/static/package_json.a83729efdb0697b12396.js +22 -0
  22. package/dist/web/static/web_index_tsx.e5a01ac0e4b0a6f6517f.js +21 -0
  23. package/index.ts +8 -0
  24. package/instance.ts +7 -0
  25. package/module/config/_file_loader.lua +29 -0
  26. package/module/config/advanced_start.lua +112 -0
  27. package/module/config/afk_kick.lua +14 -0
  28. package/module/config/bonus.lua +105 -0
  29. package/module/config/chat_reply.lua +136 -0
  30. package/module/config/compilatron.lua +25 -0
  31. package/module/config/death_logger.lua +15 -0
  32. package/module/config/deconlog.lua +11 -0
  33. package/module/config/discord_alerts.lua +25 -0
  34. package/module/config/expcore/permission_groups.lua +143 -0
  35. package/module/config/graftorio.lua +7 -0
  36. package/module/config/gui/autofill.lua +129 -0
  37. package/module/config/gui/player_list_actions.lua +201 -0
  38. package/module/config/gui/rockets.lua +47 -0
  39. package/module/config/gui/science.lua +21 -0
  40. package/module/config/gui/tasks.lua +13 -0
  41. package/module/config/gui/warps.lua +52 -0
  42. package/module/config/inventory_clear.lua +9 -0
  43. package/module/config/join_messages.lua +8 -0
  44. package/module/config/lawnmower.lua +6 -0
  45. package/module/config/logging.lua +30 -0
  46. package/module/config/miner.lua +8 -0
  47. package/module/config/module.lua +86 -0
  48. package/module/config/nukeprotect.lua +30 -0
  49. package/module/config/pollution_grading.lua +9 -0
  50. package/module/config/popup_messages.lua +10 -0
  51. package/module/config/preset_player_colours.lua +33 -0
  52. package/module/config/preset_player_quickbar.lua +6 -0
  53. package/module/config/protection.lua +17 -0
  54. package/module/config/repair.lua +8 -0
  55. package/module/config/research.lua +179 -0
  56. package/module/config/scorched_earth.lua +116 -0
  57. package/module/config/spawn_area.lua +255 -0
  58. package/module/config/station_auto_name.lua +11 -0
  59. package/module/config/statistics.lua +46 -0
  60. package/module/config/vlayer.lua +180 -0
  61. package/module/config/warnings.lua +38 -0
  62. package/module/control.lua +46 -0
  63. package/module/expcore/datastore.lua +884 -0
  64. package/module/expcore/external.lua +146 -0
  65. package/module/expcore/permission_groups.lua +355 -0
  66. package/module/expcore/player_data.lua +152 -0
  67. package/module/locale/en/addons.cfg +31 -0
  68. package/module/locale/en/data.cfg +114 -0
  69. package/module/locale/en/expcore.cfg +16 -0
  70. package/module/locale/en/gui.cfg +114 -0
  71. package/module/locale/zh-CN/addons.cfg +31 -0
  72. package/module/locale/zh-CN/data.cfg +114 -0
  73. package/module/locale/zh-CN/expcore.cfg +16 -0
  74. package/module/locale/zh-CN/gui.cfg +122 -0
  75. package/module/locale/zh-TW/addons.cfg +31 -0
  76. package/module/locale/zh-TW/data.cfg +114 -0
  77. package/module/locale/zh-TW/expcore.cfg +16 -0
  78. package/module/locale/zh-TW/gui.cfg +122 -0
  79. package/module/module.json +14 -0
  80. package/module/module_exports.lua +3 -0
  81. package/module/modules/control/jail.lua +119 -0
  82. package/module/modules/control/protection.lua +204 -0
  83. package/module/modules/control/reports.lua +225 -0
  84. package/module/modules/control/spectate.lua +173 -0
  85. package/module/modules/control/vlayer.lua +807 -0
  86. package/module/modules/control/warnings.lua +331 -0
  87. package/module/modules/control/warps.lua +488 -0
  88. package/module/modules/data/alt-view.lua +26 -0
  89. package/module/modules/data/greetings.lua +45 -0
  90. package/module/modules/data/language.lua +21 -0
  91. package/module/modules/data/player-colours.lua +63 -0
  92. package/module/modules/data/quickbar.lua +72 -0
  93. package/module/modules/data/statistics.lua +181 -0
  94. package/module/modules/data/tag.lua +82 -0
  95. package/module/modules/data/toolbar.lua +31 -0
  96. package/module/modules/graftorio/forcestats.lua +196 -0
  97. package/module/modules/graftorio/general.lua +63 -0
  98. package/module/modules/graftorio/require.lua +28 -0
  99. package/module/modules/graftorio/statics.lua +36 -0
  100. package/module/modules/gui/vlayer.lua +547 -0
  101. package/module/modules/gui/warp-list.lua +909 -0
  102. package/module/utils/event.lua +86 -0
  103. package/package.json +38 -0
  104. package/tsconfig.browser.json +4 -0
  105. package/tsconfig.json +7 -0
  106. package/tsconfig.node.json +5 -0
  107. package/web/index.tsx +0 -0
  108. package/webpack.config.js +29 -0
@@ -0,0 +1,225 @@
1
+ --[[-- Control Module - Reports
2
+ - Adds a way to report players and store report messages.
3
+ @control Reports
4
+ @alias Reports
5
+
6
+ @usage
7
+ -- import the module from the control modules
8
+ local Reports = require("modules.exp_legacy.modules.control.reports") --- @dep modules.control.reports
9
+
10
+ -- This will place a report on "MrBiter" (must be a valid player) the report will have been made
11
+ -- by "Cooldude2606" (must be the player name) with the reason 'Liking biters too much' this can be
12
+ -- seen by using Reports.get_report.
13
+ Reports.report_player('MrBiter', 'Cooldude2606', 'Liking biters too much') -- true
14
+
15
+ -- The other get methods can be used to get all the reports on a player or to test if a player is reported.
16
+ Reports.get_report('MrBiter', 'Cooldude2606') -- 'Liking biters too much'
17
+
18
+ -- This will remove the warning on 'MrBiter' (must be a valid player) which was made by 'Cooldude2606'.
19
+ Reports.remove_report('MrBiter', 'Cooldude2606') -- true
20
+
21
+ -- This will remove all the report that have been made against 'MrBiter'. Note that the remove event will
22
+ -- be triggered once per report issused.
23
+ Reports.remove_all('MrBiter') -- true
24
+
25
+ ]]
26
+
27
+ local Storage = require("modules/exp_util/storage")
28
+
29
+ local valid_player = function(p) return type(p) == "userdata" and p or game.get_player(p) end
30
+
31
+ local Reports = {
32
+ user_reports = {}, -- stores all user reports, global table
33
+ events = {
34
+ --- When a player is reported
35
+ -- @event on_player_reported
36
+ -- @tparam number player_index the player index of the player who got reported
37
+ -- @tparam string by_player_name the name of the player who made the report
38
+ -- @tparam string reason the reason given for the report
39
+ on_player_reported = script.generate_event_name(),
40
+ --- When a report is removed from a player
41
+ -- @event on_report_removed
42
+ -- @tparam number player_index the player index of the player who has the report removed
43
+ -- @tparam string reported_by_name the name of the player who made the removed report
44
+ -- @tparam string removed_by_name the name of the player who removed the report
45
+ -- @tparam number batch_count the number of reports removed in this batch, always one when not a batch
46
+ -- @tparam number batch the index of this event in a batch, always one when not a batch
47
+ on_report_removed = script.generate_event_name(),
48
+ },
49
+ }
50
+
51
+ local user_reports = Reports.user_reports
52
+ Storage.register(user_reports, function(tbl)
53
+ Reports.user_reports = tbl
54
+ user_reports = Reports.user_reports
55
+ end)
56
+
57
+ --- Getters.
58
+ -- Functions used to get information from reports
59
+ -- @section get-functions
60
+
61
+ --- Gets a list of all reports that a player has against them
62
+ -- @tparam LuaPlayer player the player to get the report for
63
+ -- @treturn table a list of all reports, key is by player name, value is reason
64
+ function Reports.get_reports(player)
65
+ player = valid_player(player)
66
+ if not player then return end
67
+
68
+ return user_reports[player.name] or {}
69
+ end
70
+
71
+ --- Gets a single report against a player given the name of the player who made the report
72
+ -- @tparam LuaPlayer player the player to get the report for
73
+ -- @tparam string by_player_name the name of the player who made the report
74
+ -- @treturn ?string|nil string is the reason that the player was reported, if the player is not reported
75
+ function Reports.get_report(player, by_player_name)
76
+ player = valid_player(player)
77
+ if not player then return end
78
+ if not by_player_name then return end
79
+
80
+ local reports = user_reports[player.name]
81
+ return reports and reports[by_player_name]
82
+ end
83
+
84
+ --- Checks if a player is reported, option to get if reported by a certain player
85
+ -- @tparam LuaPlayer player the player to check if reported
86
+ -- @tparam[opt] string by_player_name when given will check if reported by this player
87
+ -- @treturn boolean if the player has been reported
88
+ function Reports.is_reported(player, by_player_name)
89
+ player = valid_player(player)
90
+ if not player then return end
91
+
92
+ local reports = user_reports[player.name] or {}
93
+ if by_player_name then
94
+ return reports[by_player_name] ~= nil
95
+ else
96
+ return table_size(reports) > 0
97
+ end
98
+ end
99
+
100
+ --- Counts the number of reports that a player has aganist them
101
+ -- @tparam LuaPlayer player the player to count the reports for
102
+ -- @tparam[opt] function custom_count when given this function will be used to count the reports
103
+ -- @treturn number the number of reports that the user has
104
+ function Reports.count_reports(player, custom_count)
105
+ player = valid_player(player)
106
+ if not player then return end
107
+
108
+ local reports = user_reports[player.name] or {}
109
+ if custom_count then
110
+ local ctn = 0
111
+ for by_player_name, reason in pairs(reports) do
112
+ ctn = ctn + custom_count(player, by_player_name, reason)
113
+ end
114
+
115
+ return ctn
116
+ else
117
+ return table_size(reports)
118
+ end
119
+ end
120
+
121
+ --- Setters.
122
+ -- Functions used to get information from reports
123
+ -- @section set-functions
124
+
125
+ --- Adds a report to a player, each player can only report another player once
126
+ -- @tparam LuaPlayer player the player to add the report to
127
+ -- @tparam string by_player_name the name of the player that is making the report
128
+ -- @tparam[opt='Non given.'] string reason the reason that the player is being reported
129
+ -- @treturn boolean whether the report was added successfully
130
+ function Reports.report_player(player, by_player_name, reason)
131
+ player = valid_player(player)
132
+ if not player then return end
133
+ local player_name = player.name
134
+
135
+ if reason == nil or not reason:find("%S") then reason = "No reason given" end
136
+
137
+ local reports = user_reports[player_name]
138
+ if not reports then
139
+ reports = {}
140
+ user_reports[player_name] = reports
141
+ end
142
+
143
+ if reports[by_player_name] then
144
+ return false
145
+ else
146
+ reports[by_player_name] = reason
147
+ end
148
+
149
+ script.raise_event(Reports.events.on_player_reported, {
150
+ name = Reports.events.on_player_reported,
151
+ tick = game.tick,
152
+ player_index = player.index,
153
+ by_player_name = by_player_name,
154
+ reason = reason,
155
+ })
156
+
157
+ return true
158
+ end
159
+
160
+ --- Used to emit the report removed event, own function due to repeated use in Report.remove_all
161
+ -- @tparam LuaPlayer player the player who is having the report removed from them
162
+ -- @tparam string reported_by_name the player who had the report
163
+ -- @tparam string removed_by_name the player who is clearing the report
164
+ -- @tparam number batch the index of this event in a batch, always one when not a batch
165
+ -- @tparam number batch_count the number of reports removed in this batch, always one when not a batch
166
+ local function report_removed_event(player, reported_by_name, removed_by_name, batch, batch_count)
167
+ script.raise_event(Reports.events.on_report_removed, {
168
+ name = Reports.events.on_report_removed,
169
+ tick = game.tick,
170
+ player_index = player.index,
171
+ reported_by_name = reported_by_name,
172
+ removed_by_name = removed_by_name,
173
+ batch_count = batch_count or 1,
174
+ batch = batch or 1,
175
+ })
176
+ end
177
+
178
+ --- Removes a report from a player
179
+ -- @tparam LuaPlayer player the player to remove the report from
180
+ -- @tparam string reported_by_name the name of the player that made the report
181
+ -- @tparam string removed_by_name the name of the player who removed the report
182
+ -- @treturn boolean whether the report was removed successfully
183
+ function Reports.remove_report(player, reported_by_name, removed_by_name)
184
+ player = valid_player(player)
185
+ if not player then return end
186
+
187
+ local reports = user_reports[player.name]
188
+ if not reports then
189
+ return false
190
+ end
191
+
192
+ local reason = reports[reported_by_name]
193
+ if not reason then
194
+ return false
195
+ end
196
+
197
+ report_removed_event(player, reported_by_name, removed_by_name)
198
+
199
+ reports[reported_by_name] = nil
200
+ return true
201
+ end
202
+
203
+ --- Removes all reports from a player
204
+ -- @tparam LuaPlayer player the player to remove the reports from
205
+ -- @tparam string removed_by_name the name of the player who removed the report
206
+ -- @treturn boolean whether the reports were removed successfully
207
+ function Reports.remove_all(player, removed_by_name)
208
+ player = valid_player(player)
209
+ if not player then return end
210
+
211
+ local reports = user_reports[player.name]
212
+ if not reports then
213
+ return false
214
+ end
215
+ local ctn, total = 0, #reports
216
+ for reported_by_name, _ in pairs(reports) do
217
+ ctn = ctn + 1
218
+ report_removed_event(player, reported_by_name, removed_by_name, ctn, total)
219
+ end
220
+
221
+ user_reports[player.name] = nil
222
+ return true
223
+ end
224
+
225
+ return Reports
@@ -0,0 +1,173 @@
1
+ local Storage = require("modules/exp_util/storage")
2
+ local Gui = require("modules/exp_gui")
3
+
4
+ local Event = require("modules/exp_legacy/utils/event") --- @dep utils.event
5
+
6
+ ----- Locals -----
7
+ local follow_label --- @type ExpElement Gui constructor
8
+ local following = {}
9
+ local spectating = {}
10
+ local Public = {}
11
+
12
+ ----- Storage data -----
13
+ Storage.register({
14
+ following = following,
15
+ spectating = spectating,
16
+ }, function(tbl)
17
+ following = tbl.following
18
+ spectating = tbl.spectating
19
+ end)
20
+
21
+ ----- Public Functions -----
22
+
23
+ --- Test if a player is in spectator mode
24
+ -- @tparam LuaPlayer player The player to test the controller type of
25
+ -- @treturn boolean Returns true if the player is in spectator mode
26
+ function Public.is_spectating(player)
27
+ assert(player and player.valid, "Invalid player given to follower")
28
+ return player.controller_type == defines.controllers.spectator
29
+ end
30
+
31
+ --- Puts a player into spectator mode while maintaining an association to their character
32
+ -- @tparam LuaPlayer player The player that will be placed into spectator mode
33
+ -- @treturn boolean Returns false if the player was already in spectator mode
34
+ function Public.start_spectate(player)
35
+ assert(player and player.valid, "Invalid player given to follower")
36
+ if spectating[player.index] or not player.character then return false end
37
+ local character = player.character
38
+ local opened = player.opened
39
+ player.set_controller{ type = defines.controllers.spectator }
40
+ player.associate_character(character)
41
+ spectating[player.index] = character
42
+ if opened then player.opened = opened end -- Maintain opened after controller change
43
+ return true
44
+ end
45
+
46
+ --- Return a player from spectator mode back to their character, if their character was killed then respawn them
47
+ -- @tparam LuaPlayer player The player that will leave spectator mode
48
+ function Public.stop_spectate(player)
49
+ assert(player and player.valid, "Invalid player given to follower")
50
+ local character = spectating[player.index]
51
+ spectating[player.index] = nil
52
+ if character and character.valid then
53
+ local opened = player.opened
54
+ player.teleport(character.position, character.surface)
55
+ player.set_controller{ type = defines.controllers.character, character = character }
56
+ if opened then player.opened = opened end -- Maintain opened after controller change
57
+ else
58
+ player.ticks_to_respawn = 300
59
+ end
60
+ end
61
+
62
+ --- Test if a player is in follow mode
63
+ -- @tparam LuaPlayer player The player to test the follow mode of
64
+ -- @treturn boolean Returns true if the player is in follow mode
65
+ function Public.is_following(player)
66
+ assert(player and player.valid, "Invalid player given to follower")
67
+ return following[player.index] ~= nil
68
+ end
69
+
70
+ --- Puts a player into spectator mode and follows an entity as it moves
71
+ -- @tparam LuaPlayer player The player that will follow the entity
72
+ -- @tparam ?LuaPlayer|LuaEntity entity The player or entity that will be followed
73
+ function Public.start_follow(player, entity)
74
+ assert(player and player.valid, "Invalid player given to follower")
75
+ assert(entity and entity.valid, "Invalid entity given to follower")
76
+ local spectate = Public.start_spectate(player)
77
+
78
+ player.close_map()
79
+ follow_label(player.gui.screen, entity)
80
+ player.teleport(entity.position, entity.surface)
81
+ following[player.index] = { player, entity, entity.position, spectate }
82
+ end
83
+
84
+ --- Returns camera control to the player, will return a player to their character if start_follow placed them into spectator mode
85
+ -- @tparam LuaPlayer player The player that will regain control of their camera
86
+ function Public.stop_follow(player)
87
+ assert(player and player.valid, "Invalid player given to follower")
88
+ if following[player.index] and following[player.index][4] and Public.is_spectating(player) then
89
+ Public.stop_spectate(player)
90
+ end
91
+
92
+ Gui.destroy_if_valid(player.gui.screen.follow_label)
93
+ following[player.index] = nil
94
+ end
95
+
96
+ --- Returns camera control to all players, will return a player to their character if start_follow placed them into spectator mode
97
+ function Public.stop_all()
98
+ for key, data in pairs(following) do
99
+ Public.stop_follow(data[1])
100
+ end
101
+ end
102
+
103
+ ----- Gui -----
104
+
105
+ --- Label used to show that the player is following, also used to allow esc to stop following
106
+ follow_label = Gui.define("follow-label")
107
+ :draw(function(def, parent, target)
108
+ Gui.destroy_if_valid(parent.follow_label)
109
+
110
+ local label = parent.add{
111
+ type = "label",
112
+ name = "follow_label",
113
+ style = "frame_title",
114
+ caption = "Following " .. target.name .. ".\nClick here or press esc to stop following.",
115
+ }
116
+
117
+ local player = Gui.get_player(parent)
118
+ local res = player.display_resolution
119
+ label.location = { 0, res.height - 150 }
120
+ label.style.width = res.width
121
+ label.style.horizontal_align = "center"
122
+ player.opened = label
123
+
124
+ return label
125
+ end)
126
+ :on_click(function(def, player, element)
127
+ Public.stop_follow(player)
128
+ end)
129
+ :on_closed(function(def, player, element)
130
+ -- Don't call set_controller during on_close as it invalidates the controller
131
+ -- Setting an invalid position (as to not equal their current) will call stop_follow on the next tick
132
+ following[player.index][3] = {}
133
+ end)
134
+
135
+ ----- Events -----
136
+
137
+ --- Updates the location of the player as well as doing some sanity checks
138
+ -- @tparam LuaPlayer player The player to update the position of
139
+ -- @tparam ?LuaPlayer|LuaEntity entity The player or entity being followed
140
+ local function update_player_location(player, entity, old_position)
141
+ if player.character or not entity.valid then
142
+ Public.stop_follow(player)
143
+ elseif player.position.x ~= old_position.x or player.position.y ~= old_position.y then
144
+ Public.stop_follow(player)
145
+ else
146
+ player.teleport(entity.position, entity.surface)
147
+ end
148
+ end
149
+
150
+ --- Updates the locations of all players currently following something
151
+ local function update_all()
152
+ for _, data in pairs(following) do
153
+ update_player_location(data[1], data[2], data[3])
154
+ data[3] = data[1].position
155
+ end
156
+ end
157
+
158
+ -- Update the location of all players each tick
159
+ Event.add(defines.events.on_tick, update_all)
160
+
161
+ -- Check for player leaving
162
+ Event.add(defines.events.on_pre_player_left_game, function(event)
163
+ local player = game.players[event.player_index]
164
+ Public.stop_follow(player)
165
+ for _, data in pairs(following) do
166
+ if data[2] == player then
167
+ Public.stop_follow(data[1])
168
+ end
169
+ end
170
+ end)
171
+
172
+ ----- Module Return -----
173
+ return Public