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

Merge pull request #299 from plague006/features_split

Move features into features folder
This commit is contained in:
Valansch 2018-11-11 20:37:16 +01:00 committed by GitHub
commit dbe845db79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 430 additions and 418 deletions

View File

@ -1,40 +1,52 @@
-- Libraries. Removing these will likely lead to game crashes
require 'config' require 'config'
require 'utils.utils' require 'utils.utils'
require 'utils.list_utils' require 'utils.list_utils'
require 'utils.math' require 'utils.math'
local Game = require 'utils.game' local Game = require 'utils.game'
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'
--require 'fish_market'
require 'reactor_meltdown'
require 'train_saviour'
require 'map_gen.shared.perlin_noise'
require 'map_layout'
require 'bot'
require 'player_colors'
-- GUIs the order determines the order they appear at the top.
require 'info'
require 'player_list'
require 'poll'
require 'tag_group'
require 'tasklist'
require 'blueprint_helper'
require 'paint'
require 'score'
require 'popup'
local Event = require 'utils.event' local Event = require 'utils.event'
local Donators = require 'resources.donators' local Donators = require 'resources.donators'
require 'map_gen.shared.perlin_noise'
require 'map_layout'
-- Specific to RedMew hosts, can be disabled safely if not hosting on RedMew servers
require 'features.bot'
-- Library modules which, if missing, will cause other feature modules to fail
require 'features.base_data'
require 'features.follow'
require 'features.user_groups'
-- Feature modules, each can be disabled
require 'features.autodeconstruct'
require 'features.corpse_util'
--require 'features.fish_market'
--require 'features.infinite_storage_chest'
require 'features.nuke_control'
require 'features.player_colors'
require 'features.reactor_meltdown'
require 'features.train_saviour'
require 'features.train_station_names'
-- Contains various commands for users and admins alike
require 'features.custom_commands'
-- GUIs the order determines the order they appear from left to right.
-- These can be safely disabled. Some map presets will add GUI modules themselves.
require 'features.gui.info'
require 'features.gui.player_list'
require 'features.gui.poll'
require 'features.gui.tag_group'
require 'features.gui.tasklist'
require 'features.gui.blueprint_helper'
require 'features.gui.paint'
require 'features.gui.score'
require 'features.gui.popup'
local function player_created(event) local function player_created(event)
local player = Game.get_player_by_index(event.player_index) local player = Game.get_player_by_index(event.player_index)

View File

@ -1,10 +1,10 @@
local Task = require 'utils.Task' local Task = require 'utils.Task'
local Event = require 'utils.event' local Event = require 'utils.event'
local Token = require 'utils.global_token' local Token = require 'utils.global_token'
local UserGroups = require 'user_groups' local UserGroups = require 'features.user_groups'
local Utils = require 'utils.utils' local Utils = require 'utils.utils'
local Game = require 'utils.game' local Game = require 'utils.game'
--local Antigrief = require 'antigrief' --local Antigrief = require 'features.antigrief'
local function invoke(cmd) local function invoke(cmd)
if not (game.player and game.player.admin) then if not (game.player and game.player.admin) then
@ -707,7 +707,7 @@ commands.add_command(
) )
commands.add_command('a', 'Admin chat. Messages all other admins (Admins only)', admin_chat) commands.add_command('a', 'Admin chat. Messages all other admins (Admins only)', admin_chat)
local Report = require('report') local Report = require('features.report')
local function report(cmd) local function report(cmd)
local reporting_player = game.player local reporting_player = game.player

View File

@ -19,7 +19,7 @@ make pet follow you moar
local Event = require 'utils.event' local Event = require 'utils.event'
local Token = require 'utils.global_token' local Token = require 'utils.global_token'
local Task = require 'utils.Task' local Task = require 'utils.Task'
local PlayerStats = require 'player_stats' local PlayerStats = require 'features.player_stats'
local Game = require 'utils.game' local Game = require 'utils.game'
local Utils = require 'utils.utils' local Utils = require 'utils.utils'

View File

@ -1,7 +1,7 @@
local Gui = require 'utils.gui' local Gui = require 'utils.gui'
local Global = require 'utils.global' local Global = require 'utils.global'
local Event = require 'utils.event' local Event = require 'utils.event'
local UserGroups = require 'user_groups' local UserGroups = require 'features.user_groups'
local Game = require 'utils.game' local Game = require 'utils.game'
local normal_color = {r = 1, g = 1, b = 1} local normal_color = {r = 1, g = 1, b = 1}

View File

@ -2,10 +2,10 @@ local Event = require 'utils.event'
local Global = require 'utils.global' local Global = require 'utils.global'
local Gui = require 'utils.gui' local Gui = require 'utils.gui'
local Donators = require 'resources.donators' local Donators = require 'resources.donators'
local UserGroups = require 'user_groups' local UserGroups = require 'features.user_groups'
local PlayerStats = require 'player_stats' local PlayerStats = require 'features.player_stats'
local Utils = require 'utils.utils' local Utils = require 'utils.utils'
local Report = require 'report' local Report = require 'features.report'
local Game = require 'utils.game' local Game = require 'utils.game'
local name = require "utils.math" local name = require "utils.math"

View File

@ -1,7 +1,7 @@
local Gui = require 'utils.gui' local Gui = require 'utils.gui'
local Global = require 'utils.global' local Global = require 'utils.global'
local Event = require 'utils.event' local Event = require 'utils.event'
local UserGroups = require 'user_groups' local UserGroups = require 'features.user_groups'
local Game = require 'utils.game' local Game = require 'utils.game'
local math = require "utils.math" local math = require "utils.math"
local Utils = require "utils.utils" local Utils = require "utils.utils"

View File

@ -1,7 +1,7 @@
local Event = require 'utils.event' local Event = require 'utils.event'
local Gui = require 'utils.gui' local Gui = require 'utils.gui'
local Global = require 'utils.global' local Global = require 'utils.global'
local UserGroups = require 'user_groups' local UserGroups = require 'features.user_groups'
local Game = require 'utils.game' local Game = require 'utils.game'
local Utils = require "utils.utils" local Utils = require "utils.utils"

View File

@ -1,7 +1,7 @@
local Event = require 'utils.event' local Event = require 'utils.event'
local Gui = require 'utils.gui' local Gui = require 'utils.gui'
local Global = require 'utils.global' local Global = require 'utils.global'
local UserGroups = require 'user_groups' local UserGroups = require 'features.user_groups'
local Utils = require 'utils.utils' local Utils = require 'utils.utils'
local Game = require 'utils.game' local Game = require 'utils.game'
local math = require "utils.math" local math = require "utils.math"

View File

@ -1,5 +1,5 @@
local Event = require "utils.event" local Event = require "utils.event"
local UserGroups = require "user_groups" local UserGroups = require "features.user_groups"
local Utils = require "utils.utils" local Utils = require "utils.utils"
local Game = require 'utils.game' local Game = require 'utils.game'

View File

@ -1,181 +1,181 @@
--Reactors melt down if: --Reactors melt down if:
--temperature is at 1000°C and health is 0 or reactor is picked up --temperature is at 1000°C and health is 0 or reactor is picked up
-- --
--a reactors loses 2 damage per second at 1000°C --a reactors loses 2 damage per second at 1000°C
local Event = require 'utils.event' local Event = require 'utils.event'
local Game = require 'utils.game' local Game = require 'utils.game'
global.reactors_enabled = false global.reactors_enabled = false
global.wastelands = {} global.wastelands = {}
global.reactors = {} global.reactors = {}
local wasteland_duration_seconds = 300 local wasteland_duration_seconds = 300
local function spawn_wasteland(surface, position) local function spawn_wasteland(surface, position)
local positions = { local positions = {
{0, 0}, {0, 0},
{0, 12}, {0, 12},
{0, -12}, {0, -12},
{12, 0}, {12, 0},
{-12, 0}, {-12, 0},
{-8.5, 8.5}, {-8.5, 8.5},
{-8.5, -8.5}, {-8.5, -8.5},
{8.5, -8.5}, {8.5, -8.5},
{8.5, 8.5}, {8.5, 8.5},
{4, 4}, {4, 4},
{-4, 4}, {-4, 4},
{-4, -4}, {-4, -4},
{4, -4}, {4, -4},
{13, 7.5}, {13, 7.5},
{-13, 7.5}, {-13, 7.5},
{-13, -7.5}, {-13, -7.5},
{13, -7.5}, {13, -7.5},
{7.5, 13}, {7.5, 13},
{-7.5, 13}, {-7.5, 13},
{-7.5, -13}, {-7.5, -13},
{7.5, -13}, {7.5, -13},
{0, 15}, {0, 15},
{-15, 0}, {-15, 0},
{15, 0}, {15, 0},
{0, -15} {0, -15}
} }
for _, rel_position in pairs(positions) do for _, rel_position in pairs(positions) do
surface.create_entity { surface.create_entity {
name = 'poison-capsule', name = 'poison-capsule',
position = position, position = position,
target = {position.x + rel_position[1], position.y + rel_position[2]}, target = {position.x + rel_position[1], position.y + rel_position[2]},
speed = 0.4 speed = 0.4
} }
end end
end end
local function entity_destroyed(event) local function entity_destroyed(event)
if not global.reactors_enabled or not event.entity.valid or event.entity.name ~= 'nuclear-reactor' then if not global.reactors_enabled or not event.entity.valid or event.entity.name ~= 'nuclear-reactor' then
return return
end end
local reactor = event.entity local reactor = event.entity
if reactor.temperature > 700 then if reactor.temperature > 700 then
reactor.surface.create_entity {name = 'atomic-rocket', position = reactor.position, target = reactor, speed = 1} reactor.surface.create_entity {name = 'atomic-rocket', position = reactor.position, target = reactor, speed = 1}
spawn_wasteland(reactor.surface, reactor.position) spawn_wasteland(reactor.surface, reactor.position)
global.wastelands[reactor.position.x .. '/' .. reactor.position.y] = { global.wastelands[reactor.position.x .. '/' .. reactor.position.y] = {
position = reactor.position, position = reactor.position,
surface_id = reactor.surface.index, surface_id = reactor.surface.index,
creation_time = game.tick creation_time = game.tick
} }
end end
end end
local function alert(reactor) local function alert(reactor)
for _, p in pairs(game.players) do for _, p in pairs(game.players) do
p.add_custom_alert( p.add_custom_alert(
reactor, reactor,
{type = 'item', name = 'nuclear-reactor'}, {type = 'item', name = 'nuclear-reactor'},
string.format('Reactor at %s°C', math.floor(reactor.temperature)), string.format('Reactor at %s°C', math.floor(reactor.temperature)),
true true
) )
end end
end end
local function check_reactors() local function check_reactors()
for _, surface in pairs(game.surfaces) do for _, surface in pairs(game.surfaces) do
for i, reactor in pairs(global.reactors) do for i, reactor in pairs(global.reactors) do
if reactor.valid then if reactor.valid then
if reactor.temperature > 800 then if reactor.temperature > 800 then
alert(reactor) alert(reactor)
end end
if reactor.temperature == 1000 then if reactor.temperature == 1000 then
reactor.force = 'enemy' reactor.force = 'enemy'
reactor.destructible = false reactor.destructible = false
reactor.health = 0 reactor.health = 0
reactor.surface.create_entity { reactor.surface.create_entity {
name = 'atomic-rocket', name = 'atomic-rocket',
position = reactor.position, position = reactor.position,
target = reactor, target = reactor,
speed = 1 speed = 1
} }
spawn_wasteland(reactor.surface, reactor.position) spawn_wasteland(reactor.surface, reactor.position)
global.wastelands[reactor.position.x .. '/' .. reactor.position.y] = { global.wastelands[reactor.position.x .. '/' .. reactor.position.y] = {
position = reactor.position, position = reactor.position,
surface_id = reactor.surface.index, surface_id = reactor.surface.index,
creation_time = game.tick creation_time = game.tick
} }
table.remove(global.reactors, i) table.remove(global.reactors, i)
else else
reactor.health = 500 - (reactor.temperature - 800) * 2.5 reactor.health = 500 - (reactor.temperature - 800) * 2.5
end end
else else
table.remove(global.reactors, i) table.remove(global.reactors, i)
end end
end end
global.last_reactor_warning = last_reactor_warning global.last_reactor_warning = last_reactor_warning
end end
end end
local function check_wastelands() local function check_wastelands()
for index, wl in pairs(global.wastelands) do for index, wl in pairs(global.wastelands) do
local age = game.tick - wl.creation_time local age = game.tick - wl.creation_time
wl.last_checked = wl.last_checked or 0 wl.last_checked = wl.last_checked or 0
if (game.tick - wl.last_checked) > 899 then if (game.tick - wl.last_checked) > 899 then
wl.last_checked = game.tick wl.last_checked = game.tick
spawn_wasteland(game.surfaces[wl.surface_id], wl.position) spawn_wasteland(game.surfaces[wl.surface_id], wl.position)
if age > wasteland_duration_seconds * 60 - 1 then if age > wasteland_duration_seconds * 60 - 1 then
global.wastelands[index] = nil global.wastelands[index] = nil
local reactors = local reactors =
game.surfaces[wl.surface_id].find_entities_filtered { game.surfaces[wl.surface_id].find_entities_filtered {
position = wl.position, position = wl.position,
name = 'nuclear-reactor' name = 'nuclear-reactor'
} }
if reactors[1] then if reactors[1] then
reactors[1].destroy() reactors[1].destroy()
end end
end end
end end
end end
end end
local function on_tick() local function on_tick()
if global.reactors_enabled then if global.reactors_enabled then
check_wastelands() check_wastelands()
check_reactors() check_reactors()
end end
end end
local function entity_build(event) local function entity_build(event)
if not event.created_entity.valid then if not event.created_entity.valid then
return return
end end
if event.created_entity.name == 'nuclear-reactor' and event.created_entity.surface.name ~= "antigrief" then if event.created_entity.name == 'nuclear-reactor' and event.created_entity.surface.name ~= "antigrief" then
table.insert(global.reactors, event.created_entity) table.insert(global.reactors, event.created_entity)
end end
end end
local function reactor_toggle() local function reactor_toggle()
if not game.player or game.player.admin then if not game.player or game.player.admin then
global.reactors_enabled = not global.reactors_enabled global.reactors_enabled = not global.reactors_enabled
if global.reactors_enabled then if global.reactors_enabled then
game.print('Reactor meltdown activated.') game.print('Reactor meltdown activated.')
else else
game.print('Reactor meltdown deactivated.') game.print('Reactor meltdown deactivated.')
end end
end end
end end
local function is_meltdown() local function is_meltdown()
if global.reactors_enabled then if global.reactors_enabled then
Game.player_print('Reactor meltdown is enabled.') Game.player_print('Reactor meltdown is enabled.')
else else
Game.player_print('Reactor meltdown is disabled.') Game.player_print('Reactor meltdown is disabled.')
end end
end end
commands.add_command('meltdown', 'Toggles if reactors blow up', reactor_toggle) commands.add_command('meltdown', 'Toggles if reactors blow up', reactor_toggle)
commands.add_command('is-meltdown', 'Prints if meltdown is enabled', is_meltdown) commands.add_command('is-meltdown', 'Prints if meltdown is enabled', is_meltdown)
Event.on_nth_tick(60, on_tick) Event.on_nth_tick(60, on_tick)
Event.add(defines.events.on_player_mined_entity, entity_destroyed) Event.add(defines.events.on_player_mined_entity, entity_destroyed)
Event.add(defines.events.on_robot_mined_entity, entity_destroyed) Event.add(defines.events.on_robot_mined_entity, entity_destroyed)
Event.add(defines.events.on_entity_died, entity_destroyed) Event.add(defines.events.on_entity_died, entity_destroyed)
Event.add(defines.events.on_built_entity, entity_build) Event.add(defines.events.on_built_entity, entity_build)
Event.add(defines.events.on_robot_built_entity, entity_build) Event.add(defines.events.on_robot_built_entity, entity_build)

View File

@ -1,188 +1,188 @@
local Module = {} local Module = {}
local Gui = require("utils.gui") local Gui = require("utils.gui")
local Utils = require("utils.utils"); local Utils = require("utils.utils");
local Game = require 'utils.game' local Game = require 'utils.game'
local report_frame_name = Gui.uid_name() local report_frame_name = Gui.uid_name()
local report_close_button_name = Gui.uid_name() local report_close_button_name = Gui.uid_name()
local report_tab_button_name = Gui.uid_name() local report_tab_button_name = Gui.uid_name()
local report_body_name = Gui.uid_name() local report_body_name = Gui.uid_name()
global.reports = {} global.reports = {}
global.player_report_data = {} global.player_report_data = {}
local function draw_report(parent, report_id) local function draw_report(parent, report_id)
local report = global.reports[report_id] local report = global.reports[report_id]
if report_id == 0 or not report then if report_id == 0 or not report then
parent.add {type = "label", caption="No reports yet."} parent.add {type = "label", caption="No reports yet."}
return return
end end
local reported_player_name = Game.get_player_by_index(report.reported_player_index).name local reported_player_name = Game.get_player_by_index(report.reported_player_index).name
local reporting_player_name = Game.get_player_by_index(report.reporting_player_index).name local reporting_player_name = Game.get_player_by_index(report.reporting_player_index).name
local time = Utils.format_time(report.tick) local time = Utils.format_time(report.tick)
local time_ago = Utils.format_time(game.tick - report.tick) local time_ago = Utils.format_time(game.tick - report.tick)
local message = report.message local message = report.message
Gui.clear(parent) Gui.clear(parent)
parent.add {type="label", caption="Offender: " .. reported_player_name} parent.add {type="label", caption="Offender: " .. reported_player_name}
local msg_label_pane = parent.add {type="scroll-pane", vertical_scroll_policy = "auto-and-reserve-space", horizontal_scroll_policy="never"} local msg_label_pane = parent.add {type="scroll-pane", vertical_scroll_policy = "auto-and-reserve-space", horizontal_scroll_policy="never"}
msg_label_pane.style.maximal_height = 400 msg_label_pane.style.maximal_height = 400
local msg_label = msg_label_pane.add {type="label", caption="Message: " .. message} local msg_label = msg_label_pane.add {type="label", caption="Message: " .. message}
msg_label.style.single_line = false msg_label.style.single_line = false
msg_label.style.maximal_width = 680 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=string.format("Time: %s (%s ago)", time, time_ago)}
parent.add {type="label", caption="Reported by: " .. reporting_player_name} parent.add {type="label", caption="Reported by: " .. reporting_player_name}
end end
Module.show_reports = function(player) Module.show_reports = function(player)
local reports = global.reports or {} local reports = global.reports or {}
local center = player.gui.center local center = player.gui.center
local report_frame = center[report_frame_name] local report_frame = center[report_frame_name]
if report_frame and report_frame.valid then if report_frame and report_frame.valid then
Gui.destroy(report_frame) Gui.destroy(report_frame)
end end
report_frame = center.add { report_frame = center.add {
type = 'frame', type = 'frame',
name = report_frame_name, name = report_frame_name,
direction = 'vertical', direction = 'vertical',
caption = 'User reports' caption = 'User reports'
} }
report_frame.style.maximal_width = 700 report_frame.style.maximal_width = 700
player.opened = report_frame player.opened = report_frame
if #reports > 1 then 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 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"} local tab_flow = scroll_pane.add{type="flow"}
for k,report in pairs(reports) do for k,report in pairs(reports) do
local button_cell = tab_flow.add{type="flow", caption="reportuid" .. k} local button_cell = tab_flow.add{type="flow", caption="reportuid" .. k}
button_cell.add { button_cell.add {
type="button", type="button",
name=report_tab_button_name, name=report_tab_button_name,
caption = Game.get_player_by_index(report.reported_player_index).name caption = Game.get_player_by_index(report.reported_player_index).name
} }
end end
end end
local report_body = report_frame.add {type = "scroll-pane", name = report_body_name, horizontal_scroll_policy = "never", vertical_scroll_policy="never"} 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'} report_frame.add {type = 'button', name = report_close_button_name, caption = 'Close'}
draw_report(report_body, #reports) draw_report(report_body, #reports)
end end
function Module.report(reporting_player, reported_player, message) function Module.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}) table.insert(global.reports, {reporting_player_index = reporting_player.index, reported_player_index = reported_player.index, message = message, tick = game.tick})
local notified = false local notified = false
for _,p in pairs(game.players) do for _,p in pairs(game.players) do
if p.admin and p.connected then if p.admin and p.connected then
Module.show_reports(p) Module.show_reports(p)
if p.afk_time < 3600 then notified = true end if p.afk_time < 3600 then notified = true end
end end
end end
if not notified then if not notified then
for _,p in pairs(game.players) do for _,p in pairs(game.players) do
if p.admin then if p.admin then
Module.show_reports(p) Module.show_reports(p)
end end
end end
end end
end end
Gui.on_custom_close( Gui.on_custom_close(
report_frame_name, report_frame_name,
function(event) function(event)
Gui.destroy(event.element) Gui.destroy(event.element)
end end
) )
Gui.on_click( Gui.on_click(
report_close_button_name, report_close_button_name,
function(event) function(event)
Gui.destroy(event.element.parent) Gui.destroy(event.element.parent)
end end
) )
Gui.on_click( Gui.on_click(
report_tab_button_name, report_tab_button_name,
function(event) function(event)
local center = event.player.gui.center local center = event.player.gui.center
local report_frame = center[report_frame_name] local report_frame = center[report_frame_name]
local report_uid_str = string.sub(event.element.parent.caption, 10) local report_uid_str = string.sub(event.element.parent.caption, 10)
local report_uid = tonumber(report_uid_str) local report_uid = tonumber(report_uid_str)
draw_report(report_frame[report_body_name], report_uid) draw_report(report_frame[report_body_name], report_uid)
end end
) )
local reporting_popup_name = Gui.uid_name() local reporting_popup_name = Gui.uid_name()
local reporting_cancel_button_name = Gui.uid_name() local reporting_cancel_button_name = Gui.uid_name()
local reporting_submit_button_name = Gui.uid_name() local reporting_submit_button_name = Gui.uid_name()
local reporting_input_name = Gui.uid_name() local reporting_input_name = Gui.uid_name()
Module.spawn_reporting_popup = function(player, reported_player) Module.spawn_reporting_popup = function(player, reported_player)
local center = player.gui.center local center = player.gui.center
local reporting_popup = center[reporting_popup_name] local reporting_popup = center[reporting_popup_name]
if reporting_popup and reporting_popup.valid then if reporting_popup and reporting_popup.valid then
Gui.destroy(reporting_popup) Gui.destroy(reporting_popup)
end end
reporting_popup = center.add { reporting_popup = center.add {
type = 'frame', type = 'frame',
name = reporting_popup_name, name = reporting_popup_name,
direction = 'vertical', direction = 'vertical',
caption = 'Report player ' .. reported_player.name caption = 'Report player ' .. reported_player.name
} }
Gui.set_data(reporting_popup, {reported_player_index = reported_player.index}) Gui.set_data(reporting_popup, {reported_player_index = reported_player.index})
reporting_popup.style.maximal_width = 500 reporting_popup.style.maximal_width = 500
player.opened = reporting_popup player.opened = reporting_popup
reporting_popup.add { reporting_popup.add {
type = 'label', type = 'label',
caption = 'Report message:' caption = 'Report message:'
} }
local input = reporting_popup.add {type = 'text-box', name=reporting_input_name} local input = reporting_popup.add {type = 'text-box', name=reporting_input_name}
input.style.width = 400 input.style.width = 400
input.style.height = 85 input.style.height = 85
local button_flow = reporting_popup.add {type = "flow"} local button_flow = reporting_popup.add {type = "flow"}
local submit_button = button_flow.add {type = "button", name = reporting_submit_button_name, caption="Submit"} local 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"} button_flow.add {type = "button", name = reporting_cancel_button_name, caption="Cancel"}
end end
Gui.on_custom_close( Gui.on_custom_close(
reporting_popup_name, reporting_popup_name,
function(event) function(event)
Gui.destroy(event.element) Gui.destroy(event.element)
end end
) )
Gui.on_click( Gui.on_click(
reporting_cancel_button_name, reporting_cancel_button_name,
function(event) function(event)
local frame = event.element.parent.parent local frame = event.element.parent.parent
Gui.destroy(frame) Gui.destroy(frame)
end end
) )
Gui.on_click( Gui.on_click(
reporting_submit_button_name, reporting_submit_button_name,
function(event) function(event)
local frame = event.element.parent.parent local frame = event.element.parent.parent
local msg = frame[reporting_input_name].text local msg = frame[reporting_input_name].text
local data = Gui.get_data(frame) local data = Gui.get_data(frame)
local reported_player_index = data["reported_player_index"] local reported_player_index = data["reported_player_index"]
Gui.destroy(frame) Gui.destroy(frame)
Module.report(event.player, Game.get_player_by_index(reported_player_index), msg) Module.report(event.player, Game.get_player_by_index(reported_player_index), msg)
event.player.print("Sucessfully reported " .. Game.get_player_by_index(reported_player_index).name) event.player.print("Sucessfully reported " .. Game.get_player_by_index(reported_player_index).name)
end end
) )
return Module return Module

View File

@ -2,7 +2,7 @@ local Event = require 'utils.event'
local Market_items = require 'resources.market_items' local Market_items = require 'resources.market_items'
local Global = require 'utils.global' local Global = require 'utils.global'
local Donators = require 'resources.donators' local Donators = require 'resources.donators'
local UserGroups = require 'user_groups' local UserGroups = require 'features.user_groups'
local Game = require 'utils.game' local Game = require 'utils.game'
local train_perk_flag = Donators.donator_perk_flags.train local train_perk_flag = Donators.donator_perk_flags.train

View File

@ -1,7 +1,7 @@
local Event = require 'utils.event' local Event = require 'utils.event'
local Token = require 'utils.global_token' local Token = require 'utils.global_token'
local Task = require 'utils.Task' local Task = require 'utils.Task'
local PlayerStats = require 'player_stats' local PlayerStats = require 'features.player_stats'
local Game = require 'utils.game' local Game = require 'utils.game'
local Utils = require "utils.utils" local Utils = require "utils.utils"

View File

@ -321,7 +321,7 @@ function DiggyCaveCollapse.register(cfg)
end end
if (nil ~= support_beam_entities[event.entity.name]) then if (nil ~= support_beam_entities[event.entity.name]) then
require 'popup'.player( require 'features.gui.popup'.player(
Game.get_player_by_index(player_index),[[ Game.get_player_by_index(player_index),[[
Mining entities such as walls, stone paths, concrete Mining entities such as walls, stone paths, concrete
and rocks, can cause a cave-in, be careful miner! and rocks, can cause a cave-in, be careful miner!

View File

@ -1,7 +1,7 @@
-- dependencies -- dependencies
local Config = require 'map_gen.Diggy.Config' local Config = require 'map_gen.Diggy.Config'
local Debug = require 'map_gen.Diggy.Debug' local Debug = require 'map_gen.Diggy.Debug'
local ScenarioInfo = require 'info' local ScenarioInfo = require 'features.gui.info'
local Event = require 'utils.event' local Event = require 'utils.event'
require 'utils.list_utils' require 'utils.list_utils'

View File

@ -21,7 +21,7 @@ local math = require 'utils.math'
local market_items = require "map_gen.combined.cave_miner.market_items" local market_items = require "map_gen.combined.cave_miner.market_items"
local Game = require 'utils.game' local Game = require 'utils.game'
local Info = require 'info' local Info = require 'features.gui.info'
Info.set_map_name('Cave Miner') Info.set_map_name('Cave Miner')
Info.set_map_description([[ Info.set_map_description([[

View File

@ -8,7 +8,7 @@ local Random = require 'map_gen.shared.random'
local OutpostBuilder = require 'map_gen.presets.crash_site.outpost_builder' local OutpostBuilder = require 'map_gen.presets.crash_site.outpost_builder'
local math = require 'utils.math' local math = require 'utils.math'
local degrees = math.degrees local degrees = math.degrees
local ScenarioInfo = require 'info' local ScenarioInfo = require 'features.gui.info'
-- Comment out this block if you're getting scenario info from another source. -- Comment out this block if you're getting scenario info from another source.
ScenarioInfo.set_map_name('Crashsite') ScenarioInfo.set_map_name('Crashsite')

View File

@ -1,7 +1,7 @@
local Gui = require 'utils.gui' local Gui = require 'utils.gui'
local Event = require 'utils.event' local Event = require 'utils.event'
local Global = require 'utils.global' local Global = require 'utils.global'
local PlayerStats = require 'player_stats' local PlayerStats = require 'features.player_stats'
local Game = require 'utils.game' local Game = require 'utils.game'
local math = require "utils.math" local math = require "utils.math"

View File

@ -4,7 +4,7 @@ local Global = require 'utils.global'
local Event = require 'utils.event' local Event = require 'utils.event'
local Task = require 'utils.Task' local Task = require 'utils.Task'
local Market = require 'map_gen.presets.crash_site.market' local Market = require 'map_gen.presets.crash_site.market'
local PlayerStats = require 'player_stats' local PlayerStats = require 'features.player_stats'
local b = require 'map_gen.shared.builders' local b = require 'map_gen.shared.builders'

View File

@ -105,7 +105,7 @@ end
map = b.apply_effect(map, effect) map = b.apply_effect(map, effect)
require 'spawn_control' require 'features.spawn_control'
add_spawn('left', -88, -88) add_spawn('left', -88, -88)
add_spawn('right', 88, 88) add_spawn('right', 88, 88)