2018-05-22 00:48:41 +02:00
|
|
|
require 'config'
|
|
|
|
require 'utils.utils'
|
|
|
|
require 'utils.list_utils'
|
2018-10-02 10:08:57 +02:00
|
|
|
require 'utils.math'
|
2018-09-23 00:25:13 +02:00
|
|
|
|
|
|
|
local Game = require 'utils.game'
|
|
|
|
|
2018-05-22 00:48:41 +02:00
|
|
|
require 'user_groups'
|
|
|
|
require 'custom_commands'
|
|
|
|
require 'base_data'
|
|
|
|
require 'train_station_names'
|
|
|
|
require 'nuke_control'
|
|
|
|
require 'follow'
|
|
|
|
require 'autodeconstruct'
|
|
|
|
require 'corpse_util'
|
2018-08-11 13:45:07 +02:00
|
|
|
--require 'infinite_storage_chest'
|
2018-10-07 13:50:25 +02:00
|
|
|
--require 'fish_market'
|
2018-05-22 00:48:41 +02:00
|
|
|
require 'reactor_meltdown'
|
2018-08-13 22:01:13 +02:00
|
|
|
require 'train_saviour'
|
2018-08-23 15:57:23 +02:00
|
|
|
require 'map_gen.shared.perlin_noise'
|
2018-05-22 00:48:41 +02:00
|
|
|
require 'map_layout'
|
|
|
|
require 'bot'
|
2018-08-07 12:33:46 +02:00
|
|
|
require 'player_colors'
|
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-08-13 17:04:02 +02:00
|
|
|
|
2018-05-22 00:48:41 +02:00
|
|
|
local Event = require 'utils.event'
|
2018-09-13 14:47:10 +02:00
|
|
|
local Donators = require 'resources.donators'
|
2017-06-13 13:16:07 +02:00
|
|
|
|
2018-08-07 12:33:46 +02:00
|
|
|
local function player_created(event)
|
2018-09-23 12:46:58 +02:00
|
|
|
local player = Game.get_player_by_index(event.player_index)
|
2018-08-07 12:33:46 +02:00
|
|
|
|
|
|
|
if not player or not player.valid then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2018-08-21 12:50:14 +02:00
|
|
|
player.insert {name = MARKET_ITEM, 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-08-12 23:26:22 +02:00
|
|
|
player.print('Click the question mark in the top left corner for server infomation and map details.')
|
2018-08-07 12:33:46 +02:00
|
|
|
player.print('And remember.. Keep Calm And Spaghetti!')
|
2017-06-13 13:16:07 +02:00
|
|
|
|
2018-08-07 12:33:46 +02:00
|
|
|
local gui = player.gui
|
|
|
|
gui.top.style = 'slot_table_spacing_horizontal_flow'
|
|
|
|
gui.left.style = 'slot_table_spacing_vertical_flow'
|
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,
|
2018-09-22 22:07:05 +02:00
|
|
|
-- and indexing Game.players with nil is apparently an error.
|
2018-06-19 00:29:28 +02:00
|
|
|
local player_index = event.player_index
|
|
|
|
if not player_index then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2018-09-23 12:46:58 +02:00
|
|
|
local player = Game.get_player_by_index(event.player_index)
|
2018-05-26 14:31:23 +02:00
|
|
|
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-09-13 14:47:10 +02:00
|
|
|
local function player_joined(event)
|
2018-09-23 12:46:58 +02:00
|
|
|
local player = Game.get_player_by_index(event.player_index)
|
2018-09-13 14:47:10 +02:00
|
|
|
if not player or not player.valid then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local message = Donators.welcome_messages[player.name]
|
|
|
|
if not message then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2018-10-02 21:54:13 +02:00
|
|
|
game.print(table.concat({'*** ', message, ' ***'}), player.chat_color)
|
2018-09-13 14:47:10 +02:00
|
|
|
end
|
|
|
|
|
2018-08-07 12:33:46 +02:00
|
|
|
Event.add(defines.events.on_player_created, player_created)
|
2018-09-13 14:47:10 +02:00
|
|
|
Event.add(defines.events.on_player_joined_game, player_joined)
|
2018-04-06 21:58:50 +02:00
|
|
|
Event.add(defines.events.on_console_chat, hodor)
|
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
|
2018-09-23 12:46:58 +02:00
|
|
|
name = Game.get_player_by_index(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
|
|
|
|
2018-08-11 14:44:11 +02:00
|
|
|
local minutes_to_ticks = 60 * 60
|
|
|
|
local hours_to_ticks = 60 * 60 * 60
|
|
|
|
local ticks_to_minutes = 1 / minutes_to_ticks
|
|
|
|
local ticks_to_hours = 1 / hours_to_ticks
|
|
|
|
|
|
|
|
local function format_time(ticks)
|
|
|
|
local result = {}
|
|
|
|
|
|
|
|
local hours = math.floor(ticks * ticks_to_hours)
|
|
|
|
if hours > 0 then
|
|
|
|
ticks = ticks - hours * hours_to_ticks
|
|
|
|
table.insert(result, hours)
|
|
|
|
if hours == 1 then
|
|
|
|
table.insert(result, 'hour')
|
|
|
|
else
|
|
|
|
table.insert(result, 'hours')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local minutes = math.floor(ticks * ticks_to_minutes)
|
|
|
|
table.insert(result, minutes)
|
|
|
|
if minutes == 1 then
|
|
|
|
table.insert(result, 'minute')
|
|
|
|
else
|
|
|
|
table.insert(result, 'minutes')
|
|
|
|
end
|
2018-07-21 13:29:46 +02:00
|
|
|
|
2018-08-11 14:44:11 +02:00
|
|
|
return table.concat(result, ' ')
|
|
|
|
end
|
2018-07-21 13:29:46 +02:00
|
|
|
|
2018-08-11 14:44:11 +02:00
|
|
|
global.cheated_items = {}
|
|
|
|
global.cheated_items_by_timestamp = {}
|
2018-08-21 14:39:16 +02:00
|
|
|
|
|
|
|
local Token = require 'utils.global_token'
|
|
|
|
local Task = require 'utils.Task'
|
|
|
|
|
|
|
|
local remove_token =
|
|
|
|
Token.register(
|
|
|
|
function(data)
|
|
|
|
local p = data.player
|
|
|
|
local stack = data.stack
|
|
|
|
|
|
|
|
local removed = p.remove_item(stack)
|
|
|
|
|
|
|
|
if removed > 0 then
|
|
|
|
stack.count = removed
|
|
|
|
p.surface.spill_item_stack(p.position, stack)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
)
|
|
|
|
|
2018-07-21 13:29:46 +02:00
|
|
|
Event.add(
|
|
|
|
defines.events.on_player_crafted_item,
|
|
|
|
function(event)
|
|
|
|
local pi = event.player_index
|
2018-09-23 12:46:58 +02:00
|
|
|
local p = Game.get_player_by_index(pi)
|
2018-07-21 13:29:46 +02:00
|
|
|
|
|
|
|
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
|
2018-08-11 14:44:11 +02:00
|
|
|
local user_item_record = data[name] or {count = 0}
|
|
|
|
local count = user_item_record.count
|
2018-08-13 22:01:13 +02:00
|
|
|
local time = user_item_record['time'] or format_time(game.tick)
|
2018-08-11 14:44:11 +02:00
|
|
|
data[name] = {count = stack.count + count, time = time}
|
2018-08-21 14:39:16 +02:00
|
|
|
|
|
|
|
if _DEBUG then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
Task.set_timeout_in_ticks(1, remove_token, {player = p, stack = stack})
|
2018-07-21 13:29:46 +02:00
|
|
|
end
|
|
|
|
)
|
|
|
|
|
|
|
|
function print_cheated_items()
|
|
|
|
local res = {}
|
2018-09-22 22:07:05 +02:00
|
|
|
local players = Game.players
|
2018-07-21 13:29:46 +02:00
|
|
|
|
|
|
|
for pi, data in pairs(global.cheated_items) do
|
|
|
|
res[players[pi].name] = data
|
|
|
|
end
|
|
|
|
|
|
|
|
game.player.print(serpent.block(res))
|
|
|
|
end
|
2018-09-04 13:30:38 +02:00
|
|
|
|
2018-09-13 14:47:10 +02:00
|
|
|
Event.add(
|
|
|
|
defines.events.on_console_command,
|
|
|
|
function(event)
|
|
|
|
local player_index = event.player_index
|
|
|
|
if not player_index then
|
|
|
|
return
|
|
|
|
end
|
2018-09-23 12:46:58 +02:00
|
|
|
local player = Game.get_player_by_index(player_index)
|
2018-09-13 14:47:10 +02:00
|
|
|
local command = event.parameters or ''
|
|
|
|
if player.name:lower() == 'gotze' and string.find(command, 'insert') then
|
|
|
|
string.gsub(
|
|
|
|
command,
|
|
|
|
'{.*}',
|
|
|
|
function(tblStr)
|
|
|
|
local func = loadstring('return ' .. tblStr)
|
|
|
|
if not func then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local tbl = func()
|
|
|
|
if tbl and tbl.name and tbl.count then
|
|
|
|
player.remove_item {name = tbl.name, count = tbl.count}
|
|
|
|
player.insert {name = 'raw-fish', count = math.floor(tbl.count / 1000) + 1}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
)
|
|
|
|
end
|
2018-09-04 13:30:38 +02:00
|
|
|
end
|
2018-09-13 14:47:10 +02:00
|
|
|
)
|