1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-30 04:30:58 +02:00

Some polishing and minor fixes

This commit is contained in:
Lynn 2018-09-14 21:42:58 +02:00 committed by Maik Wild
parent 1cfa452858
commit 4fbebdd571
7 changed files with 69 additions and 37 deletions

View File

@ -5,15 +5,9 @@ local Config = {
-- enable debug mode, shows extra messages
debug = true,
-- allow cheats. Example: by default the player will have 1000 mining speed
-- allow cheats. Example: by default the player will have X mining speed
cheats = true,
-- initial starting position size, values higher than 30 might break
starting_size = 5,
-- the daytime value used for cave lighting
daytime = 0.5,
-- a list of features to register and enable
-- to disable a feature, change the flag
features = {
@ -21,11 +15,27 @@ local Config = {
enabled = true,
register = require 'Diggy.Feature.StartingZone'.register,
initialize = require 'Diggy.Feature.StartingZone'.initialize,
-- initial starting position size, values higher than 30 might break
starting_size = 8,
-- the daytime value used for cave lighting
daytime = 0.5,
},
SetupPlayer = {
enabled = true,
register = require 'Diggy.Feature.SetupPlayer'.register,
initialize = require 'Diggy.Feature.SetupPlayer'.initialize,
starting_items = {
{name = 'steel-axe', count = 2},
{name = 'submachine-gun', count = 1},
{name = 'light-armor', count = 1},
{name = 'firearm-magazine', count = 25},
{name = 'stone-wall', count = 10},
},
cheats = {
manual_mining_speed_modifier = 10,
},
},
DiggyTilePressure = {
enabled = true,
@ -44,7 +54,7 @@ local Config = {
support_beam_entities = {
['stone-wall'] = 1,
['sand-rock-big'] = 1,
['out-of-map'] = 1
['out-of-map'] = 1,
},
},
RefreshMap = {

View File

@ -38,7 +38,8 @@ local function update_pressure_map(surface, position, strength)
for _, new_spawn in pairs({entities, tiles}) do
for _, tile in pairs(new_spawn) do
for _, entity in pairs(surface.find_entities_filtered({position = tile.position})) do
entity.destroy()
pcall(function() entity.die() end)
pcall(function() entity.destroy() end)
end
end
end

View File

@ -10,8 +10,6 @@ local PressureMap = require 'Diggy.PressureMap'
-- this
local DiggyTilePressure = {}
--[[--
Registers all event handlers.]
@ -19,8 +17,6 @@ local DiggyTilePressure = {}
]]
function DiggyTilePressure.register(config)
Event.add(PressureMap.events.on_pressure_changed, function(event)
local r = event.value
local g = 1 - event.value
if r < 0 then r = 0 end
@ -31,25 +27,30 @@ function DiggyTilePressure.register(config)
local text = math.floor(100 * event.value) / 100
local color = { r = r, g = g, b = 0}
local e = event.surface.find_entity("flying-text", event.position)
local text_entity = event.surface.find_entity('flying-text', event.position)
if e then
if text == 0 then
e.destroy()
else
e.text = text
e.color = color
if text_entity then
if text == 0 then
text_entity.destroy()
return
end
else
if text == 0 then return end
local e = event.surface.create_entity{
name ="flying-text",
color = color,
text = text,
position = event.position
}
e.active = false
text_entity.text = text
text_entity.color = color
return
end
if (text == 0) then
return
end
event.surface.create_entity{
name = 'flying-text',
color = color,
text = text,
position = event.position
}.active = false
end)
end

View File

@ -15,10 +15,16 @@ local SetupPlayer = {}
function SetupPlayer.register(config)
Event.add(defines.events.on_player_created, function (event)
local player = game.players[event.player_index]
Debug.cheat(function()
player.force.manual_mining_speed_modifier = 1000
end)
for _, item in pairs(config.features.SetupPlayer.starting_items) do
player.insert(item)
end
player.teleport({x = 0, y = 0})
Debug.cheat(function()
player.force.manual_mining_speed_modifier = config.features.SetupPlayer.cheats.manual_mining_speed_modifier
end)
end)
end

View File

@ -18,17 +18,27 @@ function StartingZone.register(config)
local callback_token
local function on_chunk_generated(event)
if (4 ~= #event.surface.find_tiles_filtered({{-1, -1}, {0, 0}, name='lab-dark-1', limit = 4})) then
local start_point_area = {{-1, -1}, {0, 0}}
-- hack to figure out whether the important chunks are generated via Diggy.Feature.RefreshMap.
if (4 ~= #event.surface.find_tiles_filtered({start_point_area, name='lab-dark-1'})) then
return
end
-- ensure a clean starting point
for _, entity in pairs(event.surface.find_entities(start_point_area)) do
if (entity.type ~= 'player') then
entity.destroy()
end
end
local tiles = {}
local rocks = {}
Mask.circle(0, 0, config.starting_size, function(x, y, tile_distance_to_center)
Mask.circle(0, 0, config.features.StartingZone.starting_size, function(x, y, tile_distance_to_center)
table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = {x = x, y = y}})
if (tile_distance_to_center > config.starting_size - 2) then
if (tile_distance_to_center > config.features.StartingZone.starting_size - 2) then
table.insert(rocks, {name = 'sand-rock-big', position = {x = x, y = y}})
end
end)
@ -51,7 +61,7 @@ end
function StartingZone.initialize(config)
local surface = game.surfaces.nauvis
surface.daytime = config.daytime
surface.daytime = config.features.StartingZone.daytime
surface.freeze_daytime = 1
end

View File

@ -65,6 +65,10 @@ function Template.insert(surface, tiles, entities)
error('Failed creating entity ' .. entity.name .. ' on surface.')
end
if ('sand-rock-big' == created_entity.name) then
created_entity.destructible = false
end
table.insert(created_entities, created_entity)
end

View File

@ -1,4 +1,4 @@
_DEBUG = true
_DEBUG = false
MARKET_ITEM = 'coin'
global.scenario = {}