1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00

Merge branch 'dev_reports' into develop

This commit is contained in:
Maik Wild 2018-08-13 19:55:06 +02:00
commit 6e266f6003
17 changed files with 1300 additions and 230 deletions

View File

@ -9,7 +9,7 @@ require 'nuke_control'
require 'follow'
require 'autodeconstruct'
require 'corpse_util'
require 'infinite_storage_chest'
--require 'infinite_storage_chest'
require 'fish_market'
require 'reactor_meltdown'
require 'map_layout'
@ -25,6 +25,8 @@ require 'blueprint_helper'
require 'paint'
require 'score'
require 'popup'
require 'report'
local Event = require 'utils.event'
@ -169,8 +171,39 @@ Event.add(
end
)
global.cheated_items = {}
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
return table.concat(result, ' ')
end
global.cheated_items = {}
global.cheated_items_by_timestamp = {}
Event.add(
defines.events.on_player_crafted_item,
function(event)
@ -191,8 +224,10 @@ Event.add(
local stack = event.item_stack
local name = stack.name
local count = data[name] or 0
data[name] = stack.count + count
local user_item_record = data[name] or {count = 0}
local count = user_item_record.count
local time = user_item_record["time"] or format_time(game.tick)
data[name] = {count = stack.count + count, time = time}
end
)

View File

@ -636,39 +636,6 @@ local function admin_chat(cmd)
end
end
local function report(cmd)
if game.player then
local params = {}
for param in string.gmatch(cmd.parameter, '%S+') do
table.insert(params, param)
end
if #params < 2 then
game.player.print("Please enter then name of the offender and the reason for the report.")
return nil
end
if not game.players[params[1]] then
game.player.print(params[1] .. " does not exist.")
return nil
end
for _,p in pairs(game.players) do
if p.admin then
Utils.alert(
p,
{
"User Report",
"Offender: " .. params[1],
"Message: " .. string.sub(cmd.parameter, string.len(params[1]) + 2),
"Reported by: " .. game.player.name
}
)
end
end
end
end
commands.add_command('kill', 'Will kill you.', kill)
commands.add_command('tpplayer', '<player> - Teleports you to the player. (Admins only)', teleport_player)
commands.add_command('invoke', '<player> - Teleports the player to you. (Admins only)', invoke)
@ -728,4 +695,3 @@ commands.add_command(
unjail_player
)
commands.add_command('a', 'Admin chat. Messages all other admins (Admins only)', admin_chat)
commands.add_command('report', '<griefer-name> <message> Reports a user to admins', report)

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,106 @@
local b = require 'map_gen.shared.builders'
return b.decompress({
height = 99,
width = 127,
data = {
{1,127,},
{1,127,},
{1,127,},
{1,127,},
{1,127,},
{1,127,},
{1,85,2,13,1,29,},
{1,82,2,20,1,25,},
{1,80,2,24,1,23,},
{1,78,2,28,1,21,},
{1,77,2,31,1,19,},
{1,76,2,34,1,17,},
{1,75,2,36,1,16,},
{1,72,2,1,1,2,2,37,1,15,},
{1,70,2,2,1,2,2,39,1,14,},
{1,69,2,3,1,2,2,39,1,14,},
{1,68,2,4,1,1,2,41,1,13,},
{1,66,2,6,1,1,2,42,1,12,},
{1,65,2,6,1,2,2,43,1,11,},
{1,64,2,7,1,1,2,44,1,11,},
{1,63,2,8,1,1,2,15,1,1,2,29,1,10,},
{1,62,2,9,1,1,2,15,1,2,2,29,1,9,},
{1,61,2,10,1,1,2,12,1,2,2,2,1,1,2,29,1,9,},
{1,60,2,11,1,1,2,12,1,2,2,32,1,9,},
{1,59,2,10,1,3,2,13,1,1,2,33,1,8,},
{1,58,2,12,1,1,2,25,1,5,2,18,1,8,},
{1,57,2,13,1,1,2,23,1,9,2,17,1,7,},
{1,56,2,37,1,3,2,5,1,4,2,15,1,7,},
{1,55,2,37,1,2,2,4,1,3,2,3,1,2,2,14,1,7,},
{1,54,2,16,1,1,2,21,1,1,2,2,1,1,2,2,1,2,2,5,1,2,2,13,1,7,},
{1,53,2,17,1,1,2,20,1,2,2,7,1,1,2,1,1,1,2,3,1,2,2,12,1,7,},
{1,52,2,18,1,1,2,20,1,1,2,2,1,1,2,6,1,1,2,1,1,1,2,3,1,1,2,13,1,6,},
{1,52,2,18,1,2,2,18,1,2,2,16,1,1,2,12,1,6,},
{1,51,2,8,1,1,2,11,1,1,2,18,1,1,2,9,1,1,2,7,1,1,2,12,1,6,},
{1,50,2,8,1,2,2,10,1,2,2,18,1,1,2,18,1,1,2,11,1,6,},
{1,49,2,8,1,3,2,11,1,1,2,17,1,2,2,7,1,5,2,6,1,1,2,11,1,6,},
{1,48,2,9,1,2,2,12,1,1,2,17,1,2,2,6,1,3,2,1,1,4,2,2,1,1,2,1,1,1,2,11,1,6,},
{1,47,2,23,1,2,2,17,1,2,2,6,1,2,2,3,1,2,2,5,1,1,2,11,1,6,},
{1,46,2,25,1,1,2,17,1,2,2,5,1,2,2,3,1,3,2,5,1,1,2,11,1,6,},
{1,45,2,26,1,2,2,16,1,2,2,5,1,3,2,3,1,2,2,2,1,1,2,2,1,1,2,11,1,6,},
{1,44,2,27,1,2,2,16,1,2,2,1,1,1,2,2,1,3,2,3,1,5,2,3,1,1,2,11,1,6,},
{1,43,2,29,1,1,2,16,1,2,2,4,1,1,2,1,1,1,2,4,1,1,2,2,1,2,2,2,1,1,2,11,1,6,},
{1,43,2,29,1,1,2,17,1,1,2,6,1,8,2,3,1,2,2,11,1,6,},
{1,41,2,31,1,2,2,16,1,2,2,3,1,1,2,3,1,2,2,4,1,1,2,2,1,1,2,12,1,6,},
{1,41,2,31,1,2,2,16,1,2,2,3,1,1,2,12,1,1,2,11,1,7,},
{1,40,2,33,1,1,2,17,1,2,2,14,1,2,2,11,1,7,},
{1,39,2,10,1,2,2,22,1,2,2,17,1,1,2,11,1,1,2,2,1,1,2,12,1,7,},
{1,38,2,10,1,3,2,22,1,2,2,17,1,2,2,10,1,1,2,1,1,2,2,12,1,7,},
{1,38,2,10,1,2,2,23,1,2,2,18,1,2,2,8,1,1,2,1,1,3,2,12,1,7,},
{1,37,2,11,1,2,2,24,1,2,2,18,1,2,2,2,1,1,2,5,1,2,2,13,1,8,},
{1,36,2,38,1,2,2,19,1,10,2,14,1,8,},
{1,36,2,26,1,3,2,9,1,2,2,22,1,3,2,18,1,8,},
{1,35,2,26,1,3,2,11,1,2,2,41,1,9,},
{1,35,2,25,1,3,2,12,1,3,2,40,1,9,},
{1,34,2,42,1,2,2,39,1,10,},
{1,33,2,43,1,2,2,39,1,10,},
{1,33,2,44,1,2,2,38,1,10,},
{1,33,2,44,1,3,2,36,1,11,},
{1,32,2,8,1,2,2,36,1,2,2,35,1,12,},
{1,32,2,8,1,2,2,37,1,2,2,16,1,1,2,3,1,2,2,12,1,12,},
{1,31,2,8,1,2,2,9,1,2,2,28,1,2,2,14,1,2,2,3,1,1,2,12,1,13,},
{1,31,2,7,1,2,2,9,1,3,2,29,1,2,2,13,1,2,2,15,1,14,},
{1,31,2,18,1,1,2,32,1,2,2,29,1,14,},
{1,30,2,53,1,2,2,27,1,15,},
{1,30,2,54,1,2,2,25,1,16,},
{1,30,2,55,1,3,2,22,1,17,},
{1,29,2,57,1,3,2,20,1,18,},
{1,29,2,59,1,4,2,16,1,19,},
{1,29,2,44,1,4,2,13,1,5,2,12,1,20,},
{1,28,2,30,1,5,2,8,1,6,2,16,1,6,2,4,1,24,},
{1,28,2,29,1,4,2,35,1,31,},
{1,27,2,75,1,25,},
{1,9,2,5,1,13,2,74,1,26,},
{1,7,2,8,1,7,2,3,1,3,2,70,1,29,},
{1,7,2,8,1,6,2,5,1,5,2,66,1,30,},
{1,6,2,9,1,5,2,8,1,3,2,62,1,34,},
{1,6,2,8,1,5,2,9,1,3,2,55,1,1,2,1,1,39,},
{1,6,2,22,1,11,2,33,1,2,2,8,1,45,},
{1,6,2,22,1,14,2,35,1,50,},
{1,7,2,21,1,20,2,1,1,3,2,5,1,2,2,4,1,64,},
{1,10,2,14,1,1,2,2,1,100,},
{1,12,2,11,1,104,},
{1,11,2,8,1,1,2,1,1,106,},
{1,11,2,8,1,108,},
{1,11,2,8,1,108,},
{1,11,2,9,1,107,},
{1,10,2,9,1,108,},
{1,10,2,10,1,107,},
{1,10,2,9,1,108,},
{1,10,2,10,1,107,},
{1,11,2,8,1,108,},
{1,11,2,6,1,1,2,1,1,108,},
{1,12,2,6,1,109,},
{1,127,},
{1,127,},
{1,127,},
{1,127,},
{1,127,},
{1,127,},
}
})

View File

@ -0,0 +1,266 @@
local b = require 'map_gen.shared.builders'
return b.decompress({
height = 259,
width = 320,
data = {
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,73,2,3,1,166,2,6,1,72,},
{1,70,2,9,1,161,2,11,1,69,},
{1,68,2,12,1,158,2,15,1,67,},
{1,66,2,15,1,157,2,17,1,65,},
{1,63,2,19,1,155,2,20,1,63,},
{1,61,2,22,1,153,2,23,1,61,},
{1,60,2,24,1,151,2,26,1,59,},
{1,58,2,27,1,150,2,27,1,58,},
{1,56,2,29,1,149,2,30,1,56,},
{1,54,2,32,1,148,2,32,1,54,},
{1,53,2,33,1,66,2,15,1,66,2,35,1,52,},
{1,51,2,36,1,55,2,36,1,55,2,36,1,51,},
{1,50,2,37,1,49,2,48,1,48,2,38,1,50,},
{1,48,2,40,1,43,2,57,1,44,2,40,1,48,},
{1,47,2,41,1,39,2,65,1,39,2,42,1,47,},
{1,46,2,43,1,34,2,73,1,35,2,44,1,45,},
{1,44,2,45,1,31,2,79,1,31,2,46,1,44,},
{1,43,2,46,1,28,2,85,1,28,2,47,1,43,},
{1,42,2,48,1,24,2,91,1,25,2,49,1,41,},
{1,41,2,49,1,22,2,96,1,21,2,51,1,40,},
{1,39,2,51,1,19,2,101,1,19,2,52,1,39,},
{1,38,2,53,1,16,2,105,1,17,2,53,1,38,},
{1,37,2,54,1,14,2,109,1,14,2,55,1,37,},
{1,36,2,55,1,12,2,113,1,12,2,56,1,36,},
{1,35,2,56,1,10,2,117,1,10,2,57,1,35,},
{1,34,2,58,1,7,2,121,1,8,2,58,1,34,},
{1,33,2,59,1,7,2,121,1,7,2,60,1,33,},
{1,32,2,60,1,8,2,120,1,7,2,61,1,32,},
{1,31,2,62,1,7,2,120,1,7,2,62,1,31,},
{1,30,2,63,1,7,2,119,1,8,2,63,1,30,},
{1,29,2,64,1,7,2,119,1,7,2,65,1,29,},
{1,28,2,65,1,7,2,119,1,7,2,66,1,28,},
{1,27,2,67,1,7,2,118,1,7,2,67,1,27,},
{1,26,2,68,1,7,2,118,1,7,2,68,1,26,},
{1,25,2,69,1,7,2,117,1,8,2,69,1,25,},
{1,25,2,69,1,7,2,117,1,7,2,71,1,24,},
{1,24,2,70,1,8,2,116,1,7,2,71,1,24,},
{1,23,2,72,1,7,2,116,1,7,2,72,1,23,},
{1,22,2,73,1,7,2,116,1,7,2,73,1,22,},
{1,21,2,74,1,7,2,115,1,8,2,74,1,21,},
{1,21,2,74,1,7,2,115,1,7,2,76,1,20,},
{1,20,2,75,1,7,2,115,1,7,2,76,1,20,},
{1,19,2,76,1,8,2,114,1,7,2,77,1,19,},
{1,18,2,78,1,7,2,114,1,7,2,78,1,18,},
{1,17,2,79,1,7,2,114,1,7,2,79,1,17,},
{1,17,2,79,1,7,2,114,1,7,2,79,1,17,},
{1,16,2,80,1,7,2,113,1,7,2,81,1,16,},
{1,15,2,81,1,7,2,113,1,7,2,82,1,15,},
{1,15,2,81,1,8,2,112,1,7,2,82,1,15,},
{1,14,2,83,1,7,2,112,1,7,2,83,1,14,},
{1,13,2,84,1,7,2,112,1,7,2,84,1,13,},
{1,13,2,84,1,7,2,112,1,7,2,84,1,13,},
{1,12,2,85,1,7,2,111,1,8,2,85,1,12,},
{1,11,2,86,1,7,2,111,1,7,2,87,1,11,},
{1,11,2,86,1,7,2,111,1,7,2,87,1,11,},
{1,10,2,87,1,7,2,111,1,7,2,88,1,10,},
{1,10,2,88,1,7,2,110,1,7,2,88,1,10,},
{1,9,2,89,1,7,2,110,1,7,2,89,1,9,},
{1,9,2,89,1,7,2,110,1,7,2,89,1,9,},
{1,9,2,89,1,7,2,110,1,7,2,89,1,9,},
{1,8,2,90,1,7,2,109,1,7,2,90,1,9,},
{1,8,2,90,1,7,2,109,1,7,2,90,1,9,},
{1,8,2,90,1,7,2,109,1,7,2,90,1,9,},
{1,9,2,89,1,7,2,109,1,7,2,90,1,9,},
{1,9,2,90,1,7,2,108,1,7,2,90,1,9,},
{1,9,2,90,1,7,2,108,1,7,2,89,1,10,},
{1,10,2,89,1,7,2,108,1,7,2,89,1,10,},
{1,10,2,89,1,7,2,108,1,7,2,88,1,11,},
{1,11,2,88,1,7,2,108,1,7,2,88,1,11,},
{1,11,2,88,1,7,2,107,1,8,2,87,1,12,},
{1,12,2,87,1,7,2,107,1,8,2,86,1,13,},
{1,13,2,86,1,7,2,107,1,7,2,86,1,14,},
{1,14,2,85,1,7,2,107,1,7,2,86,1,14,},
{1,14,2,85,1,7,2,107,1,7,2,84,1,16,},
{1,16,2,83,1,8,2,106,1,7,2,83,1,17,},
{1,17,2,83,1,7,2,106,1,7,2,82,1,18,},
{1,18,2,82,1,7,2,106,1,7,2,81,1,19,},
{1,19,2,81,1,7,2,106,1,7,2,80,1,20,},
{1,20,2,80,1,7,2,106,1,7,2,79,1,21,},
{1,21,2,79,1,7,2,106,1,7,2,78,1,22,},
{1,23,2,77,1,7,2,106,1,7,2,76,1,24,},
{1,24,2,76,1,7,2,106,1,7,2,74,1,26,},
{1,26,2,74,1,7,2,105,1,8,2,73,1,27,},
{1,28,2,72,1,7,2,105,1,8,2,71,1,29,},
{1,29,2,71,1,7,2,105,1,7,2,70,1,31,},
{1,31,2,69,1,7,2,105,1,7,2,69,1,32,},
{1,33,2,67,1,7,2,105,1,7,2,67,1,34,},
{1,35,2,65,1,7,2,105,1,7,2,65,1,36,},
{1,36,2,64,1,8,2,104,1,7,2,63,1,38,},
{1,38,2,62,1,8,2,104,1,8,2,60,1,40,},
{1,41,2,59,1,8,2,104,1,8,2,58,1,42,},
{1,43,2,57,1,8,2,104,1,8,2,55,1,45,},
{1,45,2,54,1,9,2,104,1,9,2,52,1,47,},
{1,48,2,51,1,9,2,104,1,9,2,49,1,50,},
{1,50,2,48,1,10,2,104,1,10,2,46,1,52,},
{1,53,2,45,1,9,2,105,1,11,2,42,1,55,},
{1,56,2,41,1,10,2,106,1,11,2,38,1,58,},
{1,60,2,36,1,11,2,106,1,12,2,33,1,62,},
{1,42,2,1,1,21,2,30,1,13,2,106,1,14,2,27,1,21,2,3,1,42,},
{1,42,2,4,1,22,2,23,1,15,2,108,1,17,2,17,1,24,2,6,1,42,},
{1,41,2,8,1,27,2,11,1,19,2,108,1,56,2,8,1,42,},
{1,41,2,10,1,54,2,110,1,52,2,11,1,42,},
{1,41,2,13,1,50,2,113,1,46,2,16,1,41,},
{1,41,2,17,1,45,2,115,1,42,2,19,1,41,},
{1,40,2,21,1,40,2,118,1,38,2,22,1,41,},
{1,40,2,25,1,35,2,5,1,6,2,98,1,4,2,8,1,31,2,27,1,41,},
{1,40,2,29,1,28,2,6,1,10,2,94,1,9,2,8,1,23,2,32,1,41,},
{1,40,2,35,1,19,2,8,1,13,2,90,1,12,2,12,1,11,2,39,1,41,},
{1,40,2,60,1,16,2,88,1,14,2,62,1,40,},
{1,40,2,59,1,18,2,86,1,17,2,60,1,40,},
{1,39,2,59,1,19,2,85,1,18,2,60,1,40,},
{1,39,2,59,1,20,2,84,1,19,2,59,1,40,},
{1,39,2,58,1,21,2,83,1,21,2,58,1,40,},
{1,39,2,58,1,22,2,82,1,21,2,58,1,40,},
{1,39,2,58,1,22,2,81,1,22,2,58,1,40,},
{1,39,2,57,1,24,2,80,1,23,2,57,1,40,},
{1,39,2,57,1,24,2,79,1,24,2,57,1,40,},
{1,39,2,57,1,24,2,79,1,24,2,57,1,40,},
{1,39,2,57,1,24,2,79,1,24,2,58,1,39,},
{1,39,2,57,1,24,2,79,1,25,2,57,1,39,},
{1,39,2,56,1,26,2,78,1,25,2,57,1,39,},
{1,39,2,56,1,26,2,77,1,26,2,57,1,39,},
{1,39,2,56,1,26,2,77,1,26,2,57,1,39,},
{1,39,2,56,1,26,2,77,1,26,2,57,1,39,},
{1,39,2,56,1,26,2,77,1,26,2,57,1,39,},
{1,39,2,56,1,26,2,77,1,26,2,57,1,39,},
{1,39,2,56,1,26,2,77,1,26,2,57,1,39,},
{1,39,2,57,1,25,2,77,1,26,2,57,1,39,},
{1,39,2,57,1,24,2,79,1,25,2,57,1,39,},
{1,39,2,57,1,24,2,79,1,24,2,58,1,39,},
{1,39,2,57,1,24,2,79,1,24,2,58,1,39,},
{1,39,2,57,1,24,2,80,1,23,2,58,1,39,},
{1,39,2,58,1,22,2,81,1,23,2,58,1,39,},
{1,39,2,58,1,22,2,81,1,22,2,58,1,40,},
{1,39,2,59,1,20,2,83,1,21,2,58,1,40,},
{1,39,2,59,1,20,2,83,1,20,2,59,1,40,},
{1,39,2,60,1,18,2,85,1,19,2,59,1,40,},
{1,39,2,61,1,16,2,86,1,18,2,60,1,40,},
{1,39,2,61,1,16,2,87,1,16,2,61,1,40,},
{1,39,2,63,1,12,2,90,1,14,2,62,1,40,},
{1,40,2,63,1,10,2,92,1,12,2,63,1,40,},
{1,40,2,65,1,6,2,96,1,9,2,64,1,40,},
{1,40,2,169,1,4,2,66,1,41,},
{1,40,2,119,1,1,2,119,1,41,},
{1,40,2,109,1,21,2,109,1,41,},
{1,40,2,103,1,34,2,102,1,41,},
{1,41,2,96,1,44,2,98,1,41,},
{1,41,2,93,1,51,2,93,1,42,},
{1,41,2,90,1,23,2,11,1,24,2,89,1,42,},
{1,41,2,87,1,18,2,28,1,18,2,86,1,42,},
{1,42,2,83,1,16,2,38,1,15,2,84,1,42,},
{1,42,2,81,1,14,2,46,1,13,2,82,1,42,},
{1,42,2,79,1,12,2,53,1,13,2,78,1,43,},
{1,42,2,76,1,12,2,59,1,12,2,76,1,43,},
{1,42,2,75,1,11,2,64,1,10,2,75,1,43,},
{1,43,2,72,1,11,2,68,1,10,2,72,1,44,},
{1,43,2,71,1,10,2,72,1,9,2,71,1,44,},
{1,43,2,69,1,10,2,76,1,9,2,69,1,44,},
{1,44,2,67,1,9,2,79,1,9,2,68,1,44,},
{1,44,2,66,1,9,2,82,1,8,2,66,1,45,},
{1,44,2,65,1,8,2,85,1,8,2,65,1,45,},
{1,45,2,62,1,9,2,87,1,9,2,63,1,45,},
{1,45,2,61,1,9,2,90,1,8,2,61,1,46,},
{1,45,2,60,1,9,2,92,1,8,2,60,1,46,},
{1,46,2,59,1,8,2,25,1,2,2,39,1,2,2,26,1,8,2,58,1,47,},
{1,46,2,58,1,8,2,25,1,4,2,37,1,4,2,26,1,7,2,58,1,47,},
{1,47,2,56,1,8,2,25,1,6,2,35,1,6,2,26,1,7,2,57,1,47,},
{1,47,2,55,1,8,2,25,1,8,2,34,1,7,2,26,1,7,2,55,1,48,},
{1,48,2,53,1,8,2,26,1,8,2,33,1,8,2,27,1,7,2,54,1,48,},
{1,48,2,53,1,7,2,27,1,8,2,33,1,9,2,26,1,7,2,53,1,49,},
{1,48,2,52,1,8,2,26,1,10,2,31,1,10,2,27,1,7,2,52,1,49,},
{1,49,2,51,1,7,2,27,1,10,2,31,1,10,2,28,1,6,2,51,1,50,},
{1,50,2,49,1,7,2,28,1,10,2,31,1,10,2,28,1,7,2,50,1,50,},
{1,50,2,49,1,7,2,27,1,12,2,30,1,11,2,28,1,6,2,50,1,50,},
{1,50,2,48,1,7,2,28,1,12,2,29,1,12,2,28,1,7,2,48,1,51,},
{1,51,2,47,1,7,2,28,1,12,2,29,1,12,2,29,1,6,2,47,1,52,},
{1,51,2,47,1,7,2,28,1,12,2,29,1,12,2,29,1,6,2,47,1,52,},
{1,52,2,45,1,7,2,29,1,12,2,29,1,12,2,29,1,7,2,45,1,53,},
{1,52,2,45,1,7,2,29,1,12,2,29,1,12,2,30,1,6,2,45,1,53,},
{1,53,2,44,1,7,2,29,1,12,2,29,1,13,2,29,1,6,2,44,1,54,},
{1,54,2,43,1,7,2,28,1,13,2,29,1,13,2,29,1,6,2,44,1,54,},
{1,54,2,43,1,7,2,28,1,13,2,29,1,13,2,29,1,7,2,42,1,55,},
{1,55,2,41,1,7,2,29,1,14,2,28,1,13,2,29,1,7,2,41,1,56,},
{1,55,2,41,1,7,2,29,1,14,2,28,1,13,2,29,1,7,2,41,1,56,},
{1,56,2,40,1,7,2,29,1,14,2,28,1,13,2,29,1,7,2,40,1,57,},
{1,57,2,39,1,7,2,29,1,14,2,28,1,13,2,29,1,7,2,40,1,57,},
{1,57,2,39,1,7,2,29,1,14,2,28,1,13,2,29,1,7,2,39,1,58,},
{1,58,2,39,1,7,2,28,1,14,2,28,1,13,2,29,1,7,2,38,1,59,},
{1,59,2,38,1,7,2,29,1,12,2,29,1,13,2,29,1,7,2,38,1,59,},
{1,59,2,38,1,7,2,29,1,12,2,29,1,13,2,29,1,6,2,38,1,60,},
{1,60,2,37,1,7,2,29,1,12,2,29,1,12,2,30,1,6,2,37,1,61,},
{1,61,2,36,1,7,2,29,1,12,2,29,1,12,2,29,1,7,2,36,1,62,},
{1,62,2,36,1,7,2,28,1,12,2,29,1,12,2,29,1,6,2,37,1,62,},
{1,63,2,35,1,7,2,28,1,12,2,29,1,12,2,29,1,6,2,36,1,63,},
{1,63,2,36,1,6,2,28,1,12,2,29,1,12,2,28,1,7,2,35,1,64,},
{1,64,2,35,1,7,2,27,1,12,2,30,1,11,2,28,1,6,2,35,1,65,},
{1,65,2,34,1,8,2,27,1,10,2,31,1,10,2,28,1,7,2,34,1,66,},
{1,66,2,34,1,7,2,27,1,10,2,31,1,10,2,28,1,6,2,34,1,67,},
{1,67,2,34,1,7,2,26,1,10,2,31,1,10,2,27,1,7,2,34,1,67,},
{1,68,2,33,1,7,2,27,1,9,2,32,1,9,2,26,1,7,2,34,1,68,},
{1,69,2,33,1,7,2,26,1,8,2,33,1,8,2,27,1,6,2,34,1,69,},
{1,70,2,32,1,8,2,25,1,8,2,33,1,8,2,26,1,7,2,33,1,70,},
{1,71,2,32,1,8,2,25,1,6,2,35,1,6,2,26,1,7,2,32,1,72,},
{1,72,2,32,1,8,2,24,1,6,2,36,1,5,2,25,1,7,2,32,1,73,},
{1,72,2,33,1,8,2,24,1,3,2,39,1,3,2,25,1,7,2,32,1,74,},
{1,73,2,33,1,8,2,92,1,7,2,33,1,74,},
{1,74,2,33,1,8,2,90,1,7,2,33,1,75,},
{1,75,2,33,1,8,2,87,1,8,2,33,1,76,},
{1,76,2,33,1,9,2,84,1,8,2,33,1,77,},
{1,78,2,32,1,9,2,82,1,8,2,32,1,79,},
{1,79,2,33,1,9,2,78,1,8,2,33,1,80,},
{1,80,2,33,1,9,2,75,1,9,2,33,1,81,},
{1,81,2,34,1,9,2,71,1,9,2,34,1,82,},
{1,83,2,33,1,10,2,67,1,10,2,34,1,83,},
{1,84,2,34,1,11,2,62,1,10,2,34,1,85,},
{1,85,2,35,1,11,2,57,1,11,2,35,1,86,},
{1,87,2,35,1,12,2,52,1,11,2,36,1,87,},
{1,88,2,36,1,13,2,45,1,13,2,36,1,89,},
{1,90,2,36,1,15,2,37,1,15,2,37,1,90,},
{1,91,2,38,1,17,2,27,1,17,2,38,1,92,},
{1,93,2,39,1,26,2,4,1,25,2,40,1,93,},
{1,94,2,42,1,48,2,41,1,95,},
{1,96,2,44,1,39,2,44,1,97,},
{1,98,2,47,1,29,2,47,1,99,},
{1,99,2,58,1,5,2,58,1,100,},
{1,101,2,117,1,102,},
{1,103,2,113,1,104,},
{1,105,2,109,1,106,},
{1,107,2,105,1,108,},
{1,110,2,99,1,111,},
{1,112,2,95,1,113,},
{1,115,2,90,1,115,},
{1,118,2,84,1,118,},
{1,120,2,79,1,121,},
{1,124,2,72,1,124,},
{1,127,2,65,1,128,},
{1,131,2,57,1,132,},
{1,136,2,47,1,137,},
{1,143,2,33,1,144,},
{1,156,2,7,1,157,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
{1,320,},
}
})

View File

@ -0,0 +1,161 @@
local b = require 'map_gen.shared.builders'
local Random = require 'map_gen.shared.random'
local ore_seed = 3000
local wave = b.sine_wave(64, 16, 4)
local waves = b.single_y_pattern(wave, 64)
local bounds = b.rectangle(192, 192)
local wave_island = b.choose(bounds, waves, b.empty_shape)
local wave_island2 = b.rotate(wave_island, degrees(90))
local pattern = {
{wave_island, wave_island2},
{wave_island2, wave_island}
}
local wave_islands = b.grid_pattern(pattern, 2, 2, 192, 192)
local wave2 = b.sine_wave(64, 8, 2)
local connecting_wave = b.any {wave2, b.rotate(wave2, degrees(90))}
local connecting_waves = b.single_pattern(connecting_wave, 192, 192)
connecting_waves = b.translate(connecting_waves, 64, 64)
wave_islands = b.any {wave_islands, connecting_waves}
wave_islands = b.change_tile(wave_islands, false, 'deepwater')
wave_islands = b.rotate(wave_islands, degrees(45))
local map = b.change_map_gen_collision_tile(wave_islands, 'water-tile', 'grass-1')
map = b.scale(map, 2)
local pig = b.picture(require 'map_gen.data.presets.pig')
local ham = b.picture(require 'map_gen.data.presets.ham')
pig = b.scale(pig, 64 / 320)
ham = b.scale(ham, 64 / 127)
local ores_patch = b.circle(16)
local function value(base, mult, pow)
return function(x, y)
local d = math.sqrt(x * x + y * y)
return base + mult * d ^ pow
end
end
local function non_transform(shape)
return shape
end
local function uranium_transform(shape)
return b.scale(shape, 0.5)
end
local function oil_transform(shape)
shape = b.scale(shape, 0.5)
shape = b.throttle_world_xy(shape, 1, 5, 1, 5)
return shape
end
local ores = {
{weight = 150},
{transform = non_transform, resource = 'iron-ore', value = value(500, 0.75, 1.2), weight = 16},
{transform = non_transform, resource = 'copper-ore', value = value(400, 0.75, 1.2), weight = 10},
{transform = non_transform, resource = 'stone', value = value(250, 0.3, 1.05), weight = 3},
{transform = non_transform, resource = 'coal', value = value(400, 0.8, 1.075), weight = 8},
{transform = uranium_transform, resource = 'uranium-ore', value = value(200, 0.3, 1.025), weight = 3},
{transform = oil_transform, resource = 'crude-oil', value = value(180000, 50, 1.1), weight = 6}
}
local total_ore_weights = {}
local ore_t = 0
for _, v in ipairs(ores) do
ore_t = ore_t + v.weight
table.insert(total_ore_weights, ore_t)
end
local random_ore = Random.new(ore_seed, ore_seed * 2)
local ore_pattern = {}
for r = 1, 50 do
local row = {}
ore_pattern[r] = row
local even_r = r % 2 == 0
for c = 1, 50 do
local even_c = c % 2 == 0
local shape
if even_r == even_c then
shape = pig
else
shape = ham
end
local i = random_ore:next_int(1, ore_t)
index = table.binary_search(total_ore_weights, i)
if (index < 0) then
index = bit32.bnot(index)
end
local ore_data = ores[index]
local transform = ore_data.transform
if not transform then
row[c] = b.no_entity
else
local ore_shape = transform(shape)
local x = random_ore:next_int(-24, 24)
local y = random_ore:next_int(-24, 24)
ore_shape = b.translate(ore_shape, x, y)
local ore = b.resource(ore_shape, ore_data.resource, ore_data.value)
row[c] = ore
end
end
end
local start_pig =
b.segment_pattern {
b.resource(
pig,
'iron-ore',
function()
return 1000
end
),
b.resource(
pig,
'copper-ore',
function()
return 500
end
),
b.resource(
pig,
'coal',
function()
return 750
end
),
b.resource(
pig,
'stone',
function()
return 300
end
)
}
ore_pattern[1][1] = start_pig
local ore_grid = b.grid_pattern_full_overlap(ore_pattern, 50, 50, 96, 96)
ore_grid = b.translate(ore_grid, -50, 64)
map = b.apply_entity(map, ore_grid)
map = b.fish(map, 0.0025)
return map

View File

@ -0,0 +1,231 @@
local b = require 'map_gen.shared.builders'
local Perlin = require 'map_gen.shared.perlin_noise'
local Event = require 'utils.event'
local Global = require 'utils.global'
local oil_seed
local uranium_seed
local density_seed
local enemy_seed
local oil_scale = 1 / 64
local oil_threshold = 0.6
local uranium_scale = 1 / 128
local uranium_threshold = 0.65
local density_scale = 1 / 48
local density_threshold = 0.5
local density_multiplier = 50
Global.register_init(
{},
function(tbl)
tbl.seed = game.surfaces[1].map_gen_settings.seed
end,
function(tbl)
local seed = tbl.seed
oil_seed = seed
uranium_seed = seed * 2
density_seed = seed * 3
enemy_seed = seed * 4
end
)
local market_items = require 'resources.market_items'
table.remove(market_items, 13)
table.remove(market_items, 9)
Event.add(
defines.events.on_research_finished,
function(event)
local p_force = game.forces.player
local r = event.research
if r.name == 'flamethrower' then
p_force.recipes['flamethrower'].enabled = false
p_force.recipes['flamethrower-turret'].enabled = false
end
end
)
local trees = {
'tree-01',
'tree-02',
'tree-02-red',
'tree-03',
'tree-04',
'tree-05',
'tree-06',
'tree-06-brown',
'tree-07',
'tree-08',
'tree-08-brown',
'tree-08-red',
'tree-09',
'tree-09-brown',
'tree-09-red'
}
local trees_count = #trees
local function tree_shape(_, _, world)
local x, y = world.x, world.y
local tree = trees[math.random(trees_count)]
local dx = math.random(-1, 1)
local dy = math.random(-1, 1)
return {name = tree, position = {x + dx, y + dy}}
--return {name = tree}
end
tree_shape = b.throttle_world_xy(tree_shape, 1, 2, 1, 2)
local worm_names = {'small-worm-turret', 'medium-worm-turret', 'big-worm-turret'}
local spawner_names = {'biter-spawner', 'spitter-spawner'}
local factor = 10 / (768 * 32)
local max_chance = 1 / 6
local scale_factor = 48
local sf = 1 / scale_factor
local m = 1 / 650
local function enemy(x, y, world)
local d = math.sqrt(world.x * world.x + world.y * world.y)
if d < 68 then
return nil
end
if d < 100 then
return tree_shape(x, y, world)
end
local threshold = 1 - d * m
threshold = math.max(threshold, 0.5) -- -0.125)
x, y = x * sf, y * sf
if Perlin.noise(x, y, enemy_seed) > threshold then
if math.random(8) == 1 then
local lvl
if d < 400 then
lvl = 1
elseif d < 650 then
lvl = 2
else
lvl = 3
end
local chance = math.min(max_chance, d * factor)
if math.random() < chance then
local worm_id
if d > 512 then
local power = 512 / d
worm_id = math.ceil((math.random() ^ power) * lvl)
worm_id = math.clamp(worm_id, 1, 3)
else
worm_id = math.random(lvl)
end
return {name = worm_names[worm_id]}
end
else
local chance = math.min(max_chance, d * factor)
if math.random() < chance then
local spawner_id = math.random(2)
return {name = spawner_names[spawner_id]}
end
end
else
return tree_shape(x, y, world)
end
end
local value = b.euclidean_value
local oil_shape = b.throttle_world_xy(b.full_shape, 1, 8, 1, 8)
local oil_resource = b.resource(oil_shape, 'crude-oil', value(250000, 200))
local uranium_resource = b.resource(b.full_shape, 'uranium-ore', value(200, 1))
local ores = {
{resource = b.resource(b.full_shape, 'iron-ore', value(25, 0.5)), weight = 6},
{resource = b.resource(b.full_shape, 'copper-ore', value(25, 0.5)), weight = 4},
{resource = b.resource(b.full_shape, 'stone', value(25, 0.5)), weight = 1},
{resource = b.resource(b.full_shape, 'coal', value(25, 0.5)), weight = 2}
}
local weighted_ores = b.prepare_weighted_array(ores)
local total_ores = weighted_ores.total
local spawn_zone = b.circle(64)
local ore_circle = b.circle(68)
local start_ores = {
b.resource(ore_circle, 'iron-ore', value(100, 0)),
b.resource(ore_circle, 'copper-ore', value(50, 0)),
b.resource(ore_circle, 'coal', value(100, 0)),
b.resource(ore_circle, 'stone', value(50, 0))
}
local start_segment = b.segment_pattern(start_ores)
local function ore(x, y, world)
if spawn_zone(x, y) then
return
end
local start_ore = start_segment(x, y, world)
if start_ore then
return start_ore
end
local oil_x, oil_y = x * oil_scale, y * oil_scale
local oil_noise = Perlin.noise(oil_x, oil_y, oil_seed)
if oil_noise > oil_threshold then
return oil_resource(x, y, world)
end
local uranium_x, uranium_y = x * uranium_scale, y * uranium_scale
local uranium_noise = Perlin.noise(uranium_x, uranium_y, uranium_seed)
if uranium_noise > uranium_threshold then
return uranium_resource(x, y, world)
end
local i = math.random() * total_ores
local index = table.binary_search(weighted_ores, i)
if (index < 0) then
index = bit32.bnot(index)
end
local resource = ores[index].resource
local entity = resource(x, y, world)
local density_x, density_y = x * density_scale, y * density_scale
local density_noise = Perlin.noise(density_x, density_y, density_seed)
if density_noise > density_threshold then
entity.amount = entity.amount * density_multiplier
end
entity.enable_tree_removal = false
return entity
end
local water = b.circle(8)
water = b.change_tile(water, true, 'water-green')
water = b.any {b.rectangle(16, 4), b.rectangle(4, 16), water}
local start = b.if_else(water, b.full_shape)
start = b.change_map_gen_collision_tile(start, 'water-tile', 'grass-1')
local map = b.choose(ore_circle, start, b.full_shape)
map = b.apply_entity(map, ore)
map = b.apply_entity(map, enemy)
map = b.change_map_gen_tile(map, 'water', 'water-green')
map = b.change_map_gen_tile(map, 'deepwater', 'deepwater-green')
return map

View File

@ -125,6 +125,20 @@ function Builders.sine_fill(width, height)
end
end
function Builders.sine_wave(width, height, thickness)
local width_inv = tau / width
local height_inv = 2 / height
thickness = thickness * 0.5
return function(x, y)
local x2 = x * width_inv
local y2 = math.sin(x2)
y = y * height_inv
local d = math.abs(y2 - y)
return d < thickness
end
end
function Builders.rectangular_spiral(x_size, optional_y_size)
optional_y_size = optional_y_size or x_size

View File

@ -73,6 +73,7 @@ local tiles_per_tick = 32
--shape = require "map_gen.presets.dino_island"
--shape = require "map_gen.presets.toxic_jungle"
--shape = require "map_gen.presets.danger_ores"
--shape = require "map_gen.presets.bacon_islands"
--shape = require "map_gen.presets.test"
--shapes--

View File

@ -3,6 +3,8 @@ local Global = require 'utils.global'
local Gui = require 'utils.gui'
local UserGroups = require 'user_groups'
local PlayerStats = require 'player_stats'
local Utils = require 'utils.utils'
local Report = require 'report'
local poke_messages = require 'resources.poke_messages'
local player_sprites = require 'resources.player_sprites'
@ -16,6 +18,7 @@ local focus_color = {r = 1, g = 0.55, b = 0.1}
local rank_colors = {
{r = 1, g = 1, b = 1}, -- Guest
{r = 0.155, g = 0.540, b = 0.898}, -- Regular
{r = 172.6, g = 70.2, b = 215.8}, -- Donator {r = 152, g = 24, b = 206}
{r = 0.093, g = 0.768, b = 0.172} -- Admin
}
@ -23,6 +26,7 @@ local inv_sprite_time_step = 1 / sprite_time_step
local rank_names = {
'Guest',
'Regular',
'Donator',
'Admin'
}
@ -58,6 +62,7 @@ local distance_heading_name = Gui.uid_name()
local coin_heading_name = Gui.uid_name()
local deaths_heading_name = Gui.uid_name()
local poke_name_heading_name = Gui.uid_name()
local report_heading_name = Gui.uid_name()
local sprite_cell_name = Gui.uid_name()
local player_name_cell_name = Gui.uid_name()
@ -67,6 +72,7 @@ local distance_cell_name = Gui.uid_name()
local coin_cell_name = Gui.uid_name()
local deaths_cell_name = Gui.uid_name()
local poke_cell_name = Gui.uid_name()
local report_cell_name = Gui.uid_name()
local function lighten_color(color)
color.r = color.r * 0.6 + 0.4
@ -75,48 +81,23 @@ local function lighten_color(color)
color.a = 1
end
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
return table.concat(result, ' ')
end
local function format_distance(tiles)
return math.round(tiles * 0.001, 1) .. ' km'
end
local function get_rank_level(player)
if player.admin then
return 3
elseif UserGroups.is_regular(player.name) then
return 2
else
return 1
return 4
end
local name = player.name
if UserGroups.is_donator(name) then
return 3
elseif UserGroups.is_regular(name) then
return 2
end
return 1
end
local function do_poke_spam_protection(player)
@ -224,7 +205,7 @@ local column_builders = {
return label
end,
draw_cell = function(parent, cell_data)
local text = format_time(cell_data)
local text = Utils.format_time(cell_data)
local label = parent.add {type = 'label', name = time_cell_name, caption = text}
local label_style = label.style
@ -402,6 +383,54 @@ local column_builders = {
Gui.set_data(label, {data = data, player = player})
return label
end
},
[report_heading_name] = {
create_data = function(player)
return player
end,
sort = function(a, b)
return a.name:lower() < b.name:lower()
end,
draw_heading = function(parent, data)
local label =
parent.add {
type = 'label',
name = report_heading_name,
caption = 'Report',
tooltip = 'Report player to the admin team for griefing or breaking the rules.'
}
local label_style = label.style
apply_heading_style(label_style)
label_style.width = 58
return label
end,
draw_cell = function(parent, cell_data, data)
local parent_style = parent.style
parent_style.width = 58
parent_style.align = 'center'
local label =
parent.add {
type = 'sprite-button',
name = report_cell_name,
sprite = 'utility/force_editor_icon',
tooltip = 'Report ' .. cell_data.name
}
local label_style = label.style
label_style.align = 'center'
label_style.minimal_width = 32
label_style.height = 24
label_style.font = 'default-bold'
label_style.top_padding = 0
label_style.bottom_padding = 0
label_style.left_padding = 0
label_style.right_padding = 0
Gui.set_data(label, cell_data)
return label
end
}
@ -417,7 +446,8 @@ local function get_default_player_settings()
distance_heading_name,
coin_heading_name,
deaths_heading_name,
poke_name_heading_name
poke_name_heading_name,
report_heading_name
},
sort = -3
}
@ -708,3 +738,15 @@ Gui.on_click(
end
end
)
Gui.on_click(
report_cell_name,
function(event)
local reporting_player = event.player
local reported_player = Gui.get_data(event.element)
-- test code.
game.print(reporting_player.name .. ' has reported ' .. reported_player.name)
--Report.spawn_reporting_popup (reporting_player, reported_player)
end
)

215
report.lua Normal file
View File

@ -0,0 +1,215 @@
local Module = {}
local Gui = require("utils.gui")
local Utils = require("utils.utils");
local report_frame_name = Gui.uid_name()
local report_close_button_name = Gui.uid_name()
local report_tab_button_name = Gui.uid_name()
local report_body_name = Gui.uid_name()
global.reports = {}
global.player_report_data = {}
local function draw_report(parent, report_id)
local report = global.reports[report_id]
local reported_player_name = game.players[report.reported_player_index].name
local reporting_player_name = game.players[report.reporting_player_index].name
local time = Utils.format_time(report.tick)
local time_ago = Utils.format_time(game.tick - report.tick)
local message = report.message
for _,child in pairs(parent.children) do
Gui.remove_data_recursivly(child)
child.destroy()
end
parent.add {type="label", caption="Offender: " .. reported_player_name}
local msg_label = parent.add {type="label", caption="Message: " .. message}
msg_label.style.single_line = false
msg_label.style.maximal_width = 680
parent.add {type="label", caption=string.format("Time: %s (%s ago)", time, time_ago)}
parent.add {type="label", caption="Reported by: " .. reporting_player_name}
end
local function show_reports(player)
local reports = global.reports or {}
local center = player.gui.center
if player.opened then --Destroy whatever is open
Gui.remove_data_recursivly(player.opened)
player.opened.destroy()
end
local report_frame = center.add {
type = 'frame',
name = report_frame_name,
direction = 'vertical',
caption = 'User reports'
}
report_frame.style.maximal_width = 700
player.opened = report_frame
if #reports > 1 then
local scroll_pane = report_frame.add{type = "scroll-pane", horizontal_scroll_policy = "auto-and-reserve-space", vertical_scroll_policy="never"}
local tab_flow = scroll_pane.add{type="flow"}
for k,report in pairs(reports) do
local button_cell = tab_flow.add{type="flow", caption="reportuid" .. k}
button_cell.add {
type="button",
name=report_tab_button_name,
caption = game.players[report.reporting_player_index].name
}
end
end
local report_body = report_frame.add {type = "scroll-pane", name = report_body_name, horizontal_scroll_policy = "never", vertical_scroll_policy="never"}
report_frame.add {type = 'button', name = report_close_button_name, caption = 'Close'}
draw_report(report_body, #reports)
end
local function report(reporting_player, reported_player, message)
table.insert(global.reports, {reporting_player_index = reporting_player.index, reported_player_index = reported_player.index, message = message, tick = game.tick})
local notified = false
for _,p in pairs(game.players) do
if p.admin and p.connected then
show_reports(p)
if p.afk_time < 3600 then notified = true end
end
end
if not notified then
for _,p in pairs(game.players) do
if p.admin then
show_reports(p)
end
end
end
end
Gui.on_custom_close(
report_frame_name,
function(event)
Gui.remove_data_recursivly(event.element)
event.element.destroy()
end
)
Gui.on_click(
report_close_button_name,
function(event)
Gui.remove_data_recursivly(event.element.parent)
event.element.parent.destroy()
end
)
Gui.on_click(
report_tab_button_name,
function(event)
local center = event.player.gui.center
local report_frame = center[report_frame_name]
local report_uid_str = string.sub(event.element.parent.caption, 10)
local report_uid = tonumber(report_uid_str)
draw_report(report_frame[report_body_name], report_uid)
end
)
local reporting_popup_name = Gui.uid_name()
local reporting_cancel_button_name = Gui.uid_name()
local reporting_submit_button_name = Gui.uid_name()
local reporting_input_name = Gui.uid_name()
spawn_reporting_popup = function(player, reported_player)
local center = player.gui.center
if player.opened then --Destroy whatever is open
Gui.remove_data_recursivly(player.opened)
player.opened.destroy()
end
local reporting_popup = center.add {
type = 'frame',
name = reporting_popup_name,
direction = 'vertical',
caption = 'Report player ' .. reported_player.name
}
Gui.set_data(reporting_popup, {reported_player_index = reported_player.index})
reporting_popup.style.maximal_width = 500
player.opened = reporting_popup
reporting_popup.add {
type = 'label',
caption = 'Report message:'
}
local input = reporting_popup.add {type = 'text-box', name=reporting_input_name}
input.style.width = 400
input.style.height = 85
local button_flow = reporting_popup.add {type = "flow"}
submit_button = button_flow.add {type = "button", name = reporting_submit_button_name, caption="Submit"}
button_flow.add {type = "button", name = reporting_cancel_button_name, caption="Cancel"}
end
Gui.on_custom_close(
reporting_popup_name,
function(event)
Gui.remove_data_recursivly(event.element)
event.element.destroy()
end
)
Gui.on_click(
reporting_cancel_button_name,
function(event)
local frame = event.element.parent.parent
Gui.remove_data_recursivly(frame)
frame.destroy()
end
)
Gui.on_click(
reporting_submit_button_name,
function(event)
local frame = event.element.parent.parent
local msg = frame[reporting_input_name].text
local data = Gui.get_data(frame)
local reported_player_index = data["reported_player_index"]
Gui.remove_data_recursivly(frame)
frame.destroy()
report(event.player, game.players[reported_player_index], msg)
event.player.print("Sucessfully reported " .. game.players[reported_player_index].name)
end
)
local function report_cmd(cmd)
if game.player then
local params = {}
for param in string.gmatch(cmd.parameter, '%S+') do
table.insert(params, param)
end
if #params < 2 then
game.player.print("Please enter then name of the offender and the reason for the report.")
return nil
end
if not game.players[params[1]] then
game.player.print(params[1] .. " does not exist.")
return nil
end
report(game.player, game.players[params[1]], string.sub(cmd.parameter, string.len(params[1]) + 2))
end
end
commands.add_command('report', '<griefer-name> <message> Reports a user to admins', report_cmd)
commands.add_command('showreports', 'Shows user reports (Admins only)',
function(event)
if game.player and game.player.admin then
show_reports(game.players[event.player_index])
end
end
)
return Module

4
resources/donators.lua Normal file
View File

@ -0,0 +1,4 @@
return {
['robertkruijt'] = true,
['aldldl'] = true
}

View File

@ -57,6 +57,9 @@ return {
{price = {{'coin', 350}}, offer = {type = 'give-item', item = 'energy-shield-equipment'}},
{price = {{'coin', 350}}, offer = {type = 'give-item', item = 'personal-laser-defense-equipment'}},
{price = {{'coin', 1}}, offer = {type = 'give-item', item = 'refined-hazard-concrete'}},
{price = {{'coin', 75}}, offer = {type = 'give-item', item = 'loader'}},
{price = {{'coin', 150}}, offer = {type = 'give-item', item = 'fast-loader'}},
{price = {{'coin', 225}}, offer = {type = 'give-item', item = 'express-loader'}},
--[[ {price = {{'coin', 5}}, offer = {type = 'give-item', item = 'science-pack-1'}},
{price = {{'coin', 10}}, offer = {type = 'give-item', item = 'science-pack-2'}},

View File

@ -147,7 +147,6 @@ return {
['jedifan'] = true,
['jinnjuice'] = true,
['joe32'] = true,
['jokerofthez'] = true,
['jono777'] = true,
['judaires'] = true,
['junhinhow'] = true,
@ -157,7 +156,6 @@ return {
['kidflash'] = true,
['koretego'] = true,
['kostrahb'] = true,
['krul'] = true,
['leadhades27'] = true,
['legionmammal978'] = true,
['lejnel'] = true,
@ -599,5 +597,49 @@ return {
['thislsamerica'] = true,
['vesorakia'] = true,
['wavethrash'] = true,
['xjohnson'] = true
['xjohnson'] = true,
['Ryix'] = true,
['Mylon'] = true,
['Terminutter'] = true,
['Hafgrim'] = true,
['l3igspeck'] = true,
['lyman'] = true,
['zsintai1987'] = true,
['xubos'] = true,
['Elsa-Zhou'] = true,
['SirBlubbalot'] = true,
['bulb5'] = true,
['fellan03'] = true,
['Irx99'] = true,
['Spocks'] = true,
['OmniMancer'] = true,
['TfGuy44'] = true,
['Krul'] = true,
['moncada'] = true,
['Wr1190'] = true,
['Phoenix27833'] = true,
['reddutton'] = true,
['4yDo'] = true,
['jpszat'] = true,
['DaHolli'] = true,
['Blaster'] = true,
['BluJester'] = true,
['thisisjack'] = true,
['Appadeia'] = true,
['Scuideie-Guy'] = true,
['drakferion'] = true,
['thelegendxp'] = true,
['SteelMK'] = true,
['Marviniusus'] = true,
['FrostDestructor'] = true,
['Gorganus'] = true,
['Sirnumnum'] = true,
['telefrog'] = true,
['wrex82'] = true,
['fce2'] = true,
['wampastompa09'] = true,
['Magic'] = true,
['ReinekeWF'] = true,
['JokerOfTheZ'] = true,
['DOSorDIE'] = true
}

View File

@ -1,4 +1,5 @@
global.regulars = require 'resources.regulars'
global.donators = require 'resources.donators'
local Event = require 'utils.event'
local Utils = require 'utils.utils'
@ -66,6 +67,10 @@ function Module.get_rank(player)
end
end
function Module.is_donator(player_name)
return global.donators[player_name]
end
Event.add(
defines.events.on_player_joined_game,
function(event)

View File

@ -1,152 +1,131 @@
local Module = {}
Module.distance = function(pos1, pos2)
local dx = pos2.x - pos1.x
local dy = pos2.y - pos1.y
return math.sqrt(dx * dx + dy * dy)
end
-- rounds number (num) to certain number of decimal places (idp)
math.round = function(num, idp)
local mult = 10 ^ (idp or 0)
return math.floor(num * mult + 0.5) / mult
end
function math.clamp(num, min, max)
if num < min then
return min
elseif num > max then
return max
else
return num
end
end
Module.print_except = function(msg, player)
for _, p in pairs(game.players) do
if p.connected and p ~= player then
p.print(msg)
end
end
end
Module.print_admins = function(msg)
for _, p in pairs(game.players) do
if p.connected and p.admin then
p.print(msg)
end
end
end
Module.get_actor = function()
if game.player then
return game.player.name
end
return '<server>'
end
Module.cast_bool = function(var)
if var then
return true
else
return false
end
end
Module.find_entities_by_last_user =
function(player, surface, filters)
if type(player) == 'string' or not player then
error(
"bad argument #1 to '" ..
debug.getinfo(1, 'n').name .. "' (number or LuaPlayer expected, got " .. type(player) .. ')',
1
)
return
end
if type(surface) ~= 'table' and type(surface) ~= 'number' then
error(
"bad argument #2 to '" ..
debug.getinfo(1, 'n').name .. "' (number or LuaSurface expected, got " .. type(surface) .. ')',
1
)
return
end
local entities = {}
local surface = surface
local player = player
local filters = filters or {}
if type(surface) == 'number' then
surface = game.surfaces[surface]
end
if type(player) == 'number' then
player = game.players[player]
end
filters.force = player.force.name
for _, e in pairs(surface.find_entities_filtered(filters)) do
if e.last_user == player then
table.insert(entities, e)
end
end
return entities
end
local Gui = require("utils.gui")
local alert_frame_name = Gui.uid_name()
local alert_close_button_name = Gui.uid_name()
function Module.alert(player, lines)
if type(lines) == string then
lines = {lines}
end
local center = player.gui.center
local alert_frame = center[alert_frame_name]
if alert_frame and alert_frame.valid then
Gui.remove_data_recursivly(alert_frame)
alert_frame.destroy()
end
alert_frame =
center.add {
type = 'frame',
name = alert_frame_name,
direction = 'vertical',
caption = 'Alert'
}
alert_frame.style.maximal_width = 500
player.opened = alert_frame
for _,line in pairs(lines) do
local frame = alert_frame.add {
type = 'label',
caption = line
}
frame.style.single_line = false
end
alert_frame.add {type = 'button', name = alert_close_button_name, caption = 'Close'}
end
Gui.on_custom_close(
alert_frame_name,
function(event)
Gui.remove_data_recursivly(event.element)
event.element.destroy()
end
)
Gui.on_click(
alert_close_button_name,
function(event)
Gui.remove_data_recursivly(event.element)
event.element.parent.destroy()
end
)
Module.ternary = function(c, t, f)
if c then
return t
else
return f
end
end
return Module
local Module = {}
Module.distance = function(pos1, pos2)
local dx = pos2.x - pos1.x
local dy = pos2.y - pos1.y
return math.sqrt(dx * dx + dy * dy)
end
-- rounds number (num) to certain number of decimal places (idp)
math.round = function(num, idp)
local mult = 10 ^ (idp or 0)
return math.floor(num * mult + 0.5) / mult
end
function math.clamp(num, min, max)
if num < min then
return min
elseif num > max then
return max
else
return num
end
end
Module.print_except = function(msg, player)
for _, p in pairs(game.players) do
if p.connected and p ~= player then
p.print(msg)
end
end
end
Module.print_admins = function(msg)
for _, p in pairs(game.players) do
if p.connected and p.admin then
p.print(msg)
end
end
end
Module.get_actor = function()
if game.player then
return game.player.name
end
return '<server>'
end
Module.cast_bool = function(var)
if var then
return true
else
return false
end
end
Module.find_entities_by_last_user =
function(player, surface, filters)
if type(player) == 'string' or not player then
error(
"bad argument #1 to '" ..
debug.getinfo(1, 'n').name .. "' (number or LuaPlayer expected, got " .. type(player) .. ')',
1
)
return
end
if type(surface) ~= 'table' and type(surface) ~= 'number' then
error(
"bad argument #2 to '" ..
debug.getinfo(1, 'n').name .. "' (number or LuaSurface expected, got " .. type(surface) .. ')',
1
)
return
end
local entities = {}
local surface = surface
local player = player
local filters = filters or {}
if type(surface) == 'number' then
surface = game.surfaces[surface]
end
if type(player) == 'number' then
player = game.players[player]
end
filters.force = player.force.name
for _, e in pairs(surface.find_entities_filtered(filters)) do
if e.last_user == player then
table.insert(entities, e)
end
end
return entities
end
Module.ternary = function(c, t, f)
if c then
return t
else
return f
end
end
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
Module.format_time = function(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
return table.concat(result, ' ')
end
return Module