1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00
RedMew/control.lua

221 lines
5.8 KiB
Lua
Raw Normal View History

2018-05-22 00:48:41 +02:00
require 'config'
require 'utils.utils'
require 'utils.list_utils'
require 'user_groups'
require 'custom_commands'
require 'base_data'
require 'train_station_names'
require 'nuke_control'
require 'follow'
require 'autodeconstruct'
require 'corpse_util'
--require 'infinite_storage_chest'
2018-08-06 18:48:22 +02:00
require 'fish_market'
2018-05-22 00:48:41 +02:00
require 'reactor_meltdown'
require 'map_layout'
require 'bot'
2018-05-17 16:20:48 +02:00
-- GUIs the order determines the order they appear at the top.
2018-05-22 00:48:41 +02:00
require 'info'
require 'player_list'
require 'poll'
2018-06-14 14:32:00 +02:00
require 'tag_group'
2018-05-22 00:48:41 +02:00
require 'tasklist'
require 'blueprint_helper'
2018-06-08 19:22:23 +02:00
require 'paint'
2018-05-22 00:48:41 +02:00
require 'score'
2018-05-23 13:16:01 +02:00
require 'popup'
2018-05-17 16:20:48 +02:00
2018-05-22 00:48:41 +02:00
local Event = require 'utils.event'
2017-06-13 13:16:07 +02:00
2017-09-25 16:12:26 +02:00
local function player_joined(event)
2018-05-22 00:48:41 +02:00
local player = game.players[event.player_index]
2018-07-28 14:04:14 +02:00
player.insert {name = 'coin', count = 10}
2018-05-22 00:48:41 +02:00
player.insert {name = 'iron-gear-wheel', count = 8}
player.insert {name = 'iron-plate', count = 16}
player.print('Welcome to our Server. You can join our Discord at: redmew.com/discord')
2018-07-28 14:04:14 +02:00
player.print('And remember.. Keep Calm And Spaghetti!')
2017-06-13 13:16:07 +02:00
end
function walkabout(player_name, distance)
2018-05-22 00:48:41 +02:00
game.player.print('This command moved to /walkabout.')
2017-09-30 15:49:04 +02:00
end
2018-05-22 00:48:41 +02:00
local hodor_messages = {
{'Hodor.', 16},
{'Hodor?', 16},
{'Hodor!', 16},
{'Hodor! Hodor! Hodor! Hodor!', 4},
{'Hodor :(', 4},
{'Hodor :)', 4},
{'HOOOODOOOR!', 4},
{'( ͡° ͜ʖ ͡°)', 1},
{'☉ ‿ ⚆', 1}
}
2017-09-30 15:49:04 +02:00
local message_weight_sum = 0
2018-05-22 00:48:41 +02:00
for _, w in pairs(hodor_messages) do
message_weight_sum = message_weight_sum + w[2]
2017-09-30 15:49:04 +02:00
end
2018-06-14 17:56:36 +02:00
global.naughty_words_enabled = false
2018-05-26 14:31:23 +02:00
global.naughty_words = {
['ass'] = true,
['bugger'] = true,
2018-05-29 01:23:55 +02:00
['butt'] = true,
['bum'] = true,
['bummer'] = true,
2018-05-26 14:31:23 +02:00
['christ'] = true,
['crikey'] = true,
['darn'] = true,
['dam'] = true,
['damn'] = true,
['dang'] = true,
['dagnabit'] = true,
['dagnabbit'] = true,
['drat'] = true,
2018-05-29 01:23:55 +02:00
['fart'] = true,
2018-05-26 14:31:23 +02:00
['feck'] = true,
['frack'] = true,
2018-05-29 01:23:55 +02:00
['freaking'] = true,
2018-05-26 14:31:23 +02:00
['frick'] = true,
2018-05-29 01:23:55 +02:00
['gay'] = true,
2018-05-26 14:31:23 +02:00
['gee'] = true,
['geez'] = true,
['git'] = true,
['god'] = true,
['golly'] = true,
['gosh'] = true,
['heavens'] = true,
['heck'] = true,
['hell'] = true,
['holy'] = true,
['jerk'] = true,
['jesus'] = true,
['petes'] = true,
["pete's"] = true,
['poo'] = true,
2018-05-29 01:23:55 +02:00
['satan'] = true,
2018-05-26 14:31:23 +02:00
['willy'] = true,
['wee'] = true,
['yikes'] = true
}
local function hodor(event)
2018-05-22 00:48:41 +02:00
local message = event.message:lower()
if message:match('hodor') then
local index = math.random(1, message_weight_sum)
local message_weight_sum = 0
for _, m in pairs(hodor_messages) do
message_weight_sum = message_weight_sum + m[2]
if message_weight_sum >= index then
game.print('Hodor: ' .. m[1])
2018-05-26 14:31:23 +02:00
break
2018-05-22 00:48:41 +02:00
end
end
end
2018-05-26 14:31:23 +02:00
2018-06-19 00:29:28 +02:00
-- player_index is nil if the message came from the server,
-- and indexing game.players with nil is apparently an error.
local player_index = event.player_index
if not player_index then
return
end
2018-05-26 14:31:23 +02:00
local player = game.players[event.player_index]
if not player or not player.valid then
return
end
2018-05-22 00:48:41 +02:00
if message:match('discord') then
2018-05-26 14:31:23 +02:00
player.print('Did you ask about our discord server?')
2018-06-04 19:13:59 +02:00
player.print('You can find it here: redmew.com/discord')
2018-05-26 14:31:23 +02:00
end
if global.naughty_words_enabled then
local naughty_words = global.naughty_words
for word in message:gmatch('%S+') do
if naughty_words[word] then
game.print(player.name .. ' this is a Christian Factorio server, no swearing please!')
break
end
2018-05-22 00:48:41 +02:00
end
end
2017-06-13 13:16:07 +02:00
end
2018-04-06 21:58:50 +02:00
Event.add(defines.events.on_player_created, player_joined)
Event.add(defines.events.on_console_chat, hodor)
2018-05-22 00:48:41 +02:00
Event.add(
defines.events.on_player_joined_game,
function(event)
2018-06-04 01:42:22 +02:00
local player = game.players[event.player_index]
if not player or not player.valid then
return
end
if player.name == 'grilledham' then
-- pink
player.color = {r = 0.9290000202716064, g = 0.3860000739097595, b = 0.51399999856948853, a = 0.5}
player.chat_color = {r = 1, g = 0.51999998092651367, b = 0.63300001621246338, a = 0.5}
end
2018-05-22 00:48:41 +02:00
2018-06-04 01:42:22 +02:00
local gui = player.gui
2018-05-22 00:48:41 +02:00
gui.top.style = 'slot_table_spacing_horizontal_flow'
2018-07-14 11:33:06 +02:00
gui.left.style = 'slot_table_spacing_vertical_flow'
2018-05-22 00:48:41 +02:00
end
)
2018-07-14 11:33:06 +02:00
2018-07-02 17:34:46 +02:00
Event.add(
defines.events.on_console_command,
function(event)
local command = event.command
if command == 'c' or command == 'command' or command == 'silent-command' or command == 'hax' then
2018-07-03 21:08:39 +02:00
local p_index = event.player_index
local name
if p_index then
name = game.players[event.player_index].name
2018-07-02 17:34:46 +02:00
else
2018-07-03 21:08:39 +02:00
name = '<server>'
2018-07-02 17:34:46 +02:00
end
2018-07-03 21:08:39 +02:00
local s = table.concat {'[Command] ', name, ' /', command, ' ', event.parameters}
2018-07-02 17:34:46 +02:00
log(s)
end
2018-05-22 00:48:41 +02:00
end
)
2018-07-21 13:29:46 +02:00
global.cheated_items = {}
Event.add(
defines.events.on_player_crafted_item,
function(event)
local pi = event.player_index
local p = game.players[pi]
if not p or not p.valid or not p.cheat_mode then
return
end
local cheat_items = global.cheated_items
local data = cheat_items[pi]
if not data then
data = {}
cheat_items[pi] = data
end
local stack = event.item_stack
local name = stack.name
local count = data[name] or 0
data[name] = stack.count + count
end
)
function print_cheated_items()
local res = {}
local players = game.players
for pi, data in pairs(global.cheated_items) do
res[players[pi].name] = data
end
game.player.print(serpent.block(res))
end