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

moved math functions into math.lua

This commit is contained in:
Maik Wild 2018-10-04 17:56:49 +02:00
parent 3abd779775
commit 4a2e258ff3
16 changed files with 37 additions and 20 deletions

View File

@ -13,8 +13,11 @@ treasure chests get better with distance
random game events // earthquake, biters, rock treasure, messages
]]--
local simplex_noise = require 'map_gen.shared.simplex_noise'
local Event = require 'utils.event'
local math = require 'utils.math'
local market_items = require "map_gen.combined.cave_miner.market_items"
local Game = require 'utils.game'

View File

@ -5,6 +5,7 @@ require("util")
require("rso_resource_config")
local Utils = require "utils.utils"
local Game = require 'utils.game'
local math = require 'utils.math'
local MB=require "metaball"
local drand = require 'drand'
@ -1167,11 +1168,11 @@ local Event = require 'utils.event'
local function run_ores_module(event) -- AKA RSO_ChunkGenerated(event)
local c_x = event.area.left_top.x
local c_y = event.area.left_top.y
RSO_init()
roll_region(c_x, c_y)
roll_chunk(event.surface, c_x, c_y)
end
Event.add(defines.events.on_chunk_generated, run_ores_module)
Event.add(defines.events.on_chunk_generated, run_ores_module)

View File

@ -1,5 +1,6 @@
local b = require 'map_gen.shared.builders'
local Random = require 'map_gen.shared.random'
local math = require "utils.math"
local ore_seed1 = 11000
local ore_seed2 = ore_seed1 * 2

View File

@ -6,6 +6,7 @@ local b = require 'map_gen.shared.builders'
local Global = require('utils.global')
local Random = require 'map_gen.shared.random'
local OutpostBuilder = require 'map_gen.presets.crash_site.outpost_builder'
local math = require "utils.math"
-- leave seeds nil to have them filled in based on teh map seed.
local outpost_seed = nil --91000

View File

@ -3,6 +3,7 @@ local Event = require 'utils.event'
local Global = require 'utils.global'
local PlayerStats = require 'player_stats'
local Game = require 'utils.game'
local math = require "utils.math"
local Public = {}

View File

@ -1,6 +1,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 oil_seed
local uranium_seed

View File

@ -4,6 +4,7 @@ This map removes and adds it's own water, in terrain settings use water frequenc
This map has isolated areas, it's recommend turning biters to peaceful to reduce stress on the pathfinder.
]]
local b = require 'map_gen.shared.builders'
local math = require "utils.math"
-- change these to change the pattern.
local seed1 = 12345

View File

@ -4,6 +4,7 @@ This map removes and adds it's own water, in terrain settings use water frequenc
This map has isolated areas, it's recommend turning biters to peaceful to reduce stress on the pathfinder.
]]
local b = require 'map_gen.shared.builders'
local math = require "utils.math"
-- change these to change the pattern.
local seed1 = 17000

View File

@ -1,4 +1,5 @@
local b = require 'map_gen.shared.builders'
local math = require "utils.math"
local value = b.exponential_value

View File

@ -1,5 +1,6 @@
local b = require 'map_gen.shared.builders'
local Random = require 'map_gen.shared.random'
local math = require "utils.math"
local track_seed1 = 37000
local track_seed2 = track_seed1 * 2

View File

@ -2,6 +2,7 @@ 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 math = require "utils.math"
local oil_seed
local uranium_seed

View File

@ -7,6 +7,7 @@ local PlayerStats = require 'player_stats'
local Utils = require 'utils.utils'
local Report = require 'report'
local Game = require 'utils.game'
local name = require "utils.math"
local poke_messages = require 'resources.poke_messages'
local player_sprites = require 'resources.player_sprites'

View File

@ -3,6 +3,7 @@ local Global = require 'utils.global'
local Event = require 'utils.event'
local UserGroups = require 'user_groups'
local Game = require 'utils.game'
local math = require "utils.math"
local default_poll_duration = 300 * 60 -- in ticks
local duration_max = 3600 -- in seconds

View File

@ -4,6 +4,7 @@ local Global = require 'utils.global'
local UserGroups = require 'user_groups'
local Utils = require 'utils.utils'
local Game = require 'utils.game'
local math = require "utils.math"
local normal_color = {r = 1, g = 1, b = 1}
local focus_color = {r = 1, g = 0.55, b = 0.1}

View File

@ -9,6 +9,23 @@ math.cos = function(x)
return math.floor(_cos(x) * 10000000 + 0.5) / 10000000
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
math.clamp = function(num, min, max)
if num < min then
return min
elseif num > max then
return max
else
return num
end
end
math.sqrt2 = math.sqrt(2)
math.inv_sqrt2 = 1 / math.sqrt2

View File

@ -7,22 +7,6 @@ Module.distance = function(pos1, pos2)
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