mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-30 04:30:58 +02:00
4258568c90
* Add creep spread mechanic * Added bot ore islands, use bool flag to turn on. * Added a noise based chest spawning system for artefacts * Added coin loot from biters and mining * Track artefacts launched into space * Add Creepy map preset * Update donators.lua * Add scenario info for crashsite (#291) * Split colors resources from colors code & catchup on donators (#288) * Split colors resources from colors code * Switch back to colors * Added jail button Moved parts of the jail command to report.lua Made jailing possible from a users report. closes #215 * Added sound for new reports Admins now get a sound when a new report is created. Useful for admins that doesn't have Factorio as active window. Currently set the sound_path as utility/tutorial_notice * Split chat triggers from control * Move cheat tracking outside of control.lua * Remove player-specific code * Split donator/on_join messages out of control * Move features into features folder * Indentation fix I aimed to fix the troublesome indentation. * Added a single indent * Make sure biter modifiers are accessible for mods * Consistency change regarding table access * Added NightTime.lua Split the time assignment into a new file NightTime.lua allowing for it to be disabled. (Restore normal day/night cycle) Also added a popup when a player places a solar panel informing that they are purely cosmetic Removed the recipe for portable solar panels because they are useless, but the technology is needed. * Fixed debug print grid value to show non-rounded value * added support for hidden tiles * Add newline to eof * Fixed no newline, indentation and scope of research * crash_site outposts set hidden tile to 'grass-1' * Log items spawned by crafting in cheat mode * Newline to eof * Put responses into table * Use trigger as table key * Change name of lattice to diagonal lattice (#297) * Add Diagonal Ribbon to map presets (#294) * Reorganize control (#312) * Check for config before disabling fish market (#311) * Force diggy biters to spawn, even if there's no space (#308) * Fixed some small things from feedback and issues (#313) * Update fractal_balls.lua * Add ALo's message and color (#314) * Add join message for ALo * Add ALo's color * Typo in donators.lua * fixed tile corruption issus closes #310 (#317) * Update player_list.lua * Update diagonal_ribbon.lua (#322) * Regulars: remove duplicates and sort alphabetically (#320)
106 lines
3.4 KiB
Lua
106 lines
3.4 KiB
Lua
--[[-- info
|
|
Provides the ability to make a simple room with contents
|
|
]]
|
|
|
|
-- dependencies
|
|
local Template = require 'map_gen.Diggy.Template'
|
|
local Perlin = require 'map_gen.shared.perlin_noise'
|
|
local Event = require 'utils.event'
|
|
local Debug = require'map_gen.Diggy.Debug'
|
|
local Task = require 'utils.Task'
|
|
local Token = require 'utils.global_token'
|
|
|
|
-- this
|
|
local SimpleRoomGenerator = {}
|
|
|
|
local do_spawn_tile = Token.register(function(params)
|
|
Template.insert(params.surface, {params.tile}, {})
|
|
end)
|
|
|
|
local do_mine = Token.register(function(params)
|
|
local sand_rocks = params.surface.find_entities_filtered({position = params.position, name = 'sand-rock-big'})
|
|
|
|
if (0 == #sand_rocks) then
|
|
Debug.print_position(params.position, 'missing rock when trying to mine.')
|
|
return
|
|
end
|
|
|
|
for _, rock in pairs(sand_rocks) do
|
|
rock.die()
|
|
end
|
|
end)
|
|
|
|
local function handle_noise(name, surface, position)
|
|
Task.set_timeout_in_ticks(1, do_mine, {surface = surface, position = position})
|
|
|
|
if ('water' == name) then
|
|
-- water is slower because for some odd reason it doesn't always want to mine it properly
|
|
Task.set_timeout_in_ticks(4, do_spawn_tile, { surface = surface, tile = { name = 'deepwater-green', position = position}})
|
|
return
|
|
end
|
|
|
|
if ('dirt' == name) then
|
|
return
|
|
end
|
|
|
|
error('No noise handled for type \'' .. name .. '\'')
|
|
end
|
|
|
|
--[[--
|
|
Registers all event handlers.
|
|
]]
|
|
function SimpleRoomGenerator.register(config)
|
|
local room_noise_minimum_distance_sq = config.room_noise_minimum_distance * config.room_noise_minimum_distance
|
|
|
|
local seed
|
|
local function get_noise(surface, x, y)
|
|
seed = seed or surface.map_gen_settings.seed + surface.index + 100
|
|
return Perlin.noise(x * config.noise_variance, y * config.noise_variance, seed)
|
|
end
|
|
|
|
Event.add(Template.events.on_void_removed, function (event)
|
|
local position = event.position
|
|
local x = position.x
|
|
local y = position.y
|
|
|
|
local distance_sq = x * x + y * y
|
|
|
|
if (distance_sq <= room_noise_minimum_distance_sq) then
|
|
return
|
|
end
|
|
|
|
local surface = event.surface
|
|
local noise = get_noise(surface, x, y)
|
|
|
|
for _, noise_range in pairs(config.room_noise_ranges) do
|
|
if (noise >= noise_range.min and noise <= noise_range.max) then
|
|
handle_noise(noise_range.name, surface, position)
|
|
end
|
|
end
|
|
end)
|
|
|
|
if (config.display_room_locations) then
|
|
Event.add(defines.events.on_chunk_generated, function (event)
|
|
local surface = event.surface
|
|
local area = event.area
|
|
|
|
for x = area.left_top.x, area.left_top.x + 31 do
|
|
for y = area.left_top.y, area.left_top.y + 31 do
|
|
for _, noise_range in pairs(config.room_noise_ranges) do
|
|
local noise = get_noise(surface, x, y)
|
|
if (noise >= noise_range.min and noise <= noise_range.max) then
|
|
Debug.print_grid_value(noise_range.name, surface, {x = x, y = y}, nil, nil, true)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
function SimpleRoomGenerator.get_extra_map_info(config)
|
|
return 'Simple Room Generator, digging around might open rooms!'
|
|
end
|
|
|
|
return SimpleRoomGenerator
|