mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
Remove math and table as globals. (#647)
* Remove math and table as globals. Create exceptions for table.lua and math.lua to modify respective globals and add returns for respective globals. * Fix lint errors from table and math
This commit is contained in:
parent
f062c53868
commit
5dd9ce9f90
@ -56,7 +56,7 @@ local STD_BASE_CONTROL = 'lua52c+factorio+factorio_control+factorio_defines+fact
|
||||
--[Assume Factorio Control stage as default]--
|
||||
-------------------------------------------------------------------------------
|
||||
std = STD_CONTROL
|
||||
globals = {'print', 'math', 'table', '_DEBUG', '_CHEATS', '_DUMP_ENV', 'ServerCommands', 'Debug'} -- RedMew-specific globals
|
||||
globals = {'print', '_DEBUG', '_CHEATS', '_DUMP_ENV', 'ServerCommands', 'Debug'} -- RedMew-specific globals
|
||||
max_line_length = LINE_LENGTH
|
||||
|
||||
not_globals = NOT_GLOBALS
|
||||
|
@ -3,7 +3,7 @@
|
||||
local Game = require 'utils.game'
|
||||
local Event = require 'utils.event'
|
||||
local Color = require 'resources.color_presets'
|
||||
require 'utils.table'
|
||||
local table = require 'utils.table'
|
||||
local Hodor = require 'resources.hodor_messages'
|
||||
|
||||
local prefix = '## - '
|
||||
|
@ -8,6 +8,7 @@ local Utils = require 'utils.core'
|
||||
local Report = require 'features.report'
|
||||
local Game = require 'utils.game'
|
||||
local Color = require 'resources.color_presets'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local poke_messages = require 'resources.poke_messages'
|
||||
local player_sprites = require 'resources.player_sprites'
|
||||
@ -396,7 +397,7 @@ local column_builders = {
|
||||
sort = function(a, b)
|
||||
return a.name:lower() < b.name:lower()
|
||||
end,
|
||||
draw_heading = function(parent, data)
|
||||
draw_heading = function(parent)
|
||||
local label =
|
||||
parent.add {
|
||||
type = 'label',
|
||||
@ -410,7 +411,7 @@ local column_builders = {
|
||||
|
||||
return label
|
||||
end,
|
||||
draw_cell = function(parent, cell_data, data)
|
||||
draw_cell = function(parent, cell_data)
|
||||
local parent_style = parent.style
|
||||
parent_style.width = 58
|
||||
parent_style.align = 'center'
|
||||
@ -440,7 +441,7 @@ local column_builders = {
|
||||
}
|
||||
|
||||
local function get_default_player_settings()
|
||||
columns = {
|
||||
local columns = {
|
||||
sprite_heading_name,
|
||||
player_name_heading_name,
|
||||
time_heading_name,
|
||||
|
@ -1,3 +1,4 @@
|
||||
-- dependencies
|
||||
local Event = require 'utils.event'
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
@ -5,14 +6,20 @@ local PlayerStats = require 'features.player_stats'
|
||||
local Game = require 'utils.game'
|
||||
local Command = require 'utils.command'
|
||||
local Retailer = require 'features.retailer'
|
||||
local table = require 'utils.table'
|
||||
local market_items = require 'resources.market_items'
|
||||
local fish_market_bonus_message = require 'resources.fish_messages'
|
||||
|
||||
-- localized functions
|
||||
|
||||
local pairs = pairs
|
||||
local random = math.random
|
||||
local format = string.format
|
||||
local get_random = table.get_random
|
||||
local currency = global.config.market.currency
|
||||
|
||||
-- local vars
|
||||
|
||||
local running_speed_boost_messages = {
|
||||
'%s found the lost Dragon Scroll and got a lv.1 speed boost!',
|
||||
'Guided by Master Oogway, %s got a lv.2 speed boost!',
|
||||
|
@ -1,4 +1,4 @@
|
||||
require 'utils.table'
|
||||
local table = require 'utils.table'
|
||||
local Game = require 'utils.game'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
|
@ -2,8 +2,7 @@
|
||||
Provides the ability to collapse caves when digging.
|
||||
]]
|
||||
-- dependencies
|
||||
require 'utils.table'
|
||||
|
||||
local table = require 'utils.table'
|
||||
local Event = require 'utils.event'
|
||||
local Template = require 'map_gen.Diggy.Template'
|
||||
local ScoreTable = require 'map_gen.Diggy.ScoreTable'
|
||||
|
@ -9,13 +9,13 @@
|
||||
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local math = require 'utils.math'
|
||||
local table = require 'utils.table'
|
||||
local degrees = math.rad
|
||||
local ore_seed1 = 7000
|
||||
local ore_seed2 = ore_seed1 * 2
|
||||
local noise = require 'map_gen.shared.perlin_noise'.noise
|
||||
local abs = math.abs
|
||||
|
||||
require 'utils.table'
|
||||
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local random = Random.new(ore_seed1, ore_seed2)
|
||||
|
@ -14,6 +14,7 @@ local Tetrimino = {}
|
||||
-- @field 3 table of numbers thrid row
|
||||
-- @field 4 table of numbers forth row
|
||||
|
||||
local table = require 'utils.table'
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
local Queue = require 'utils.queue'
|
||||
|
@ -1,6 +1,7 @@
|
||||
-- For more info on the day/night cycle and examples of cycles see: https://github.com/Refactorio/RedMew/wiki/Day-Night-cycle
|
||||
local Public = {}
|
||||
local Debug = require 'utils.debug'
|
||||
local math = require 'utils.math'
|
||||
|
||||
local day_night_cycle_keys = {
|
||||
'ticks_per_day',
|
||||
|
@ -1,4 +1,5 @@
|
||||
local Token = require 'utils.token'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local item_pool = {
|
||||
{name = 'firearm-magazine', count = 200, weight = 1250},
|
||||
|
@ -17,9 +17,11 @@ TODO: Look into triggering existing unit groups to attack in unison with the gro
|
||||
|
||||
-- Dependencies
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local random = math.random
|
||||
local insert = table.insert
|
||||
local Global = require 'utils.global'
|
||||
|
||||
-- config settings
|
||||
-- basic interval for checks
|
||||
|
@ -1,4 +1,4 @@
|
||||
require 'utils.table'
|
||||
local table = require 'utils.table'
|
||||
local Game = require 'utils.game'
|
||||
local Event = require 'utils.event'
|
||||
local naming_words = require 'resources.naming_words'
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- adds some wrecked items around the map, good for MP, reduces total resources pulled from factory, and adds incentive to push out
|
||||
|
||||
local table = require 'utils.table'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
local wreck_item_pool = {
|
||||
@ -50,7 +50,7 @@ local callback =
|
||||
end
|
||||
)
|
||||
|
||||
return function(x, y, world)
|
||||
return function()
|
||||
local ship = table.get_random(entity_list, true)
|
||||
|
||||
if math.random(ship.chance) ~= 1 then
|
||||
|
@ -1,4 +1,5 @@
|
||||
local Global = require 'utils.global'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local seed = nil -- Set to number to force seed.
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local degrees = require "utils.math".degrees
|
||||
local table = require 'utils.table'
|
||||
|
||||
local ore_seed = 3000
|
||||
|
||||
|
@ -2,6 +2,7 @@ local b = require 'map_gen.shared.builders'
|
||||
local perlin = require 'map_gen.shared.perlin_noise'
|
||||
local Global = require 'utils.global'
|
||||
local math = require 'utils.math'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local sand_width = 512
|
||||
local sand_width_inv = math.tau / sand_width
|
||||
|
@ -7,7 +7,7 @@ local Token = require 'utils.token'
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local ScenarioInfo = require 'features.gui.info'
|
||||
require 'utils.table'
|
||||
local table = require 'utils.table'
|
||||
|
||||
ScenarioInfo.set_map_name('Christmas Tree of Terror')
|
||||
ScenarioInfo.set_map_description("Triangle of death's Christmas cousin")
|
||||
|
@ -1,6 +1,7 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local math = require "utils.math"
|
||||
local table = require 'utils.table'
|
||||
|
||||
local ore_seed1 = 11000
|
||||
local ore_seed2 = ore_seed1 * 2
|
||||
|
@ -1,5 +1,6 @@
|
||||
local b = require "map_gen.shared.builders"
|
||||
local degrees = require "utils.math".degrees
|
||||
local table = require 'utils.table'
|
||||
|
||||
local seed1 = 666
|
||||
local seed2 = 999
|
||||
|
@ -9,6 +9,7 @@ local OutpostBuilder = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
local math = require 'utils.math'
|
||||
local degrees = math.degrees
|
||||
local ScenarioInfo = require 'features.gui.info'
|
||||
local table = require 'utils.table'
|
||||
|
||||
-- Comment out this block if you're getting scenario info from another source.
|
||||
ScenarioInfo.set_map_name('Crashsite')
|
||||
|
@ -5,6 +5,7 @@ local Event = require 'utils.event'
|
||||
local Task = require 'utils.task'
|
||||
local Retailer = require 'features.retailer'
|
||||
local PlayerStats = require 'features.player_stats'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local b = require 'map_gen.shared.builders'
|
||||
|
||||
|
@ -2,6 +2,7 @@ local b = require 'map_gen.shared.builders'
|
||||
local Perlin = require 'map_gen.shared.perlin_noise'
|
||||
local Global = require 'utils.global'
|
||||
local math = require "utils.math"
|
||||
local table = require 'utils.table'
|
||||
|
||||
local oil_seed
|
||||
local uranium_seed
|
||||
|
@ -2,6 +2,7 @@ local b = require 'map_gen.shared.builders'
|
||||
local Event = require 'utils.event'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local degrees = require "utils.math".degrees
|
||||
local table = require 'utils.table'
|
||||
|
||||
local seed = 1000
|
||||
|
||||
|
@ -6,6 +6,7 @@ This map has isolated areas, it's recommend turning biters to peaceful to reduce
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local math = require "utils.math"
|
||||
local degrees = math.degrees
|
||||
local table = require 'utils.table'
|
||||
|
||||
-- change these to change the pattern.
|
||||
local seed1 = 12345
|
||||
|
@ -5,6 +5,7 @@ This map has isolated areas, it's recommend turning biters to peaceful to reduce
|
||||
]]
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local math = require "utils.math"
|
||||
local table = require 'utils.table'
|
||||
|
||||
-- change these to change the pattern.
|
||||
local seed1 = 17000
|
||||
|
@ -3,6 +3,7 @@ This map uses custom ore gen. When generating the map, under the resource settin
|
||||
]]
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local table = require 'utils.table'
|
||||
local degrees = require "utils.math".degrees
|
||||
local ore_seed1 = 1000
|
||||
local ore_seed2 = ore_seed1 * 2
|
||||
|
@ -10,11 +10,14 @@
|
||||
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local math = require "utils.math"
|
||||
local table = require 'utils.table'
|
||||
|
||||
local degrees = math.rad
|
||||
|
||||
local ore_seed1 = 1000
|
||||
local ore_seed2 = ore_seed1 * 2
|
||||
local island_separation = 350
|
||||
local math = require "utils.math"
|
||||
local degrees = math.rad
|
||||
|
||||
local track = {
|
||||
b.translate(b.line_x(3), 0, -3),
|
||||
|
@ -1,4 +1,5 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local table = require 'utils.table'
|
||||
local degrees = require "utils.math".degrees
|
||||
|
||||
local ore_seed = 4000
|
||||
|
@ -1,4 +1,5 @@
|
||||
local b = require "map_gen.shared.builders"
|
||||
local table = require 'utils.table'
|
||||
local degrees = require "utils.math".degrees
|
||||
|
||||
local seed1 = 420420
|
||||
|
@ -1,7 +1,8 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local table = require 'utils.table'
|
||||
local math = require "utils.math"
|
||||
local degrees = require math.degrees
|
||||
local degrees = math.degrees
|
||||
|
||||
local seed1 = 17000
|
||||
local seed2 = seed1 * 2
|
||||
|
@ -1,5 +1,6 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local table = require 'utils.table'
|
||||
local math = require "utils.math"
|
||||
|
||||
local track_seed1 = 37000
|
||||
|
@ -7,7 +7,7 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local math = require "utils.math"
|
||||
local degrees = math.rad
|
||||
require 'utils.table'
|
||||
local table = require 'utils.table'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
-- change these to change the pattern.
|
||||
|
@ -1,4 +1,5 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local table = require 'utils.table'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local ore_seed1 = 2000
|
||||
local ore_seed2 = ore_seed1 * 2
|
||||
|
@ -1,4 +1,5 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local seed1 = 320420
|
||||
local seed2 = 420320
|
||||
|
@ -3,6 +3,8 @@ local Perlin = require 'map_gen.shared.perlin_noise'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local math = require "utils.math"
|
||||
local table = require 'utils.table'
|
||||
|
||||
local match = string.match
|
||||
local remove = table.remove
|
||||
|
||||
|
@ -5,7 +5,7 @@ local Token = require 'utils.token'
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local degrees = require "utils.math".degrees
|
||||
require 'utils.table'
|
||||
local table = require 'utils.table'
|
||||
|
||||
-- change these to change the pattern.
|
||||
local ore_seed1 = 30000
|
||||
|
@ -1,4 +1,5 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local seed1 = 6666
|
||||
local seed2 = 9999
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local ore_seed = 3000
|
||||
|
||||
local function no_resources(x, y, world, tile)
|
||||
|
@ -6,6 +6,9 @@
|
||||
-- dependencies
|
||||
local Global = require 'utils.global'
|
||||
local Debug = require 'utils.debug'
|
||||
local table = require 'utils.table'
|
||||
|
||||
-- localized functions
|
||||
local get_random_weighted = table.get_random_weighted
|
||||
local round = math.round
|
||||
local ceil = math.ceil
|
||||
|
@ -1,11 +1,16 @@
|
||||
-- A small debugging tool that writes the contents of _ENV to a file when the game loads.
|
||||
-- Useful for ensuring you get the same information when loading
|
||||
-- the reference and desync levels in desync reports.
|
||||
require 'utils.table'
|
||||
-- dependencies
|
||||
local table = require 'utils.table'
|
||||
local Event = require 'utils.event'
|
||||
local filename = 'env_dump.lua'
|
||||
|
||||
-- localized functions
|
||||
local inspect = table.inspect
|
||||
|
||||
-- local constants
|
||||
local filename = 'env_dump.lua'
|
||||
|
||||
-- Removes metatables and the package table
|
||||
local filter = function(item, path)
|
||||
if path[#path] ~= inspect.METATABLE and item ~= 'package' then
|
||||
|
@ -1,3 +1,4 @@
|
||||
--luacheck:ignore global math
|
||||
local _sin = math.sin
|
||||
local _cos = math.cos
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
--luacheck:ignore global table
|
||||
local random = math.random
|
||||
local floor = math.floor
|
||||
local remove = table.remove
|
||||
@ -230,3 +231,5 @@ table.merge = util.merge
|
||||
-- @param tbl2 <table>
|
||||
-- @return <boolean>
|
||||
table.equals = table.compare
|
||||
|
||||
return table
|
||||
|
Loading…
x
Reference in New Issue
Block a user