1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00
This commit is contained in:
grilledham 2018-07-21 12:29:46 +01:00
parent 26054e7f09
commit 1497e5e0ce
2 changed files with 97 additions and 46 deletions

View File

@ -180,3 +180,41 @@ Event.add(
end
end
)
global.cheated_items = {}
Event.add(
defines.events.on_player_crafted_item,
function(event)
local pi = event.player_index
local p = game.players[pi]
if not p or not p.valid or not p.cheat_mode then
return
end
local cheat_items = global.cheated_items
local data = cheat_items[pi]
if not data then
data = {}
cheat_items[pi] = data
end
local stack = event.item_stack
local name = stack.name
local count = data[name] or 0
data[name] = stack.count + count
end
)
function print_cheated_items()
local res = {}
local players = game.players
for pi, data in pairs(global.cheated_items) do
res[players[pi].name] = data
end
game.player.print(serpent.block(res))
end

View File

@ -1,13 +1,17 @@
local b = require "map_gen.shared.builders"
local b = require 'map_gen.shared.builders'
local function value(base, mult)
return function(x, y)
return function(x, y)
return mult * (math.abs(x) + math.abs(y)) + base
end
end
local function no_resources(x, y, world, tile)
for _, e in ipairs(world.surface.find_entities_filtered({ type = "resource", area = {{world.x, world.y }, {world.x + 1, world.y + 1 } } })) do
local function no_resources(x, y, world, tile)
for _, e in ipairs(
world.surface.find_entities_filtered(
{type = 'resource', area = {{world.x, world.y}, {world.x + 1, world.y + 1}}}
)
) do
e.destroy()
end
@ -19,41 +23,47 @@ local arm2 = b.translate(b.rectangle(6, 2), 0, 22)
local inner = b.circle(22)
local outer = b.circle(24)
local ring = b.all{outer, b.invert(inner)}
local ring = b.all {outer, b.invert(inner)}
map = b.any{map, ring}
map = b.any {map, ring}
local arms = b.any{arm1, arm2}
local arms = b.any {arm1, arm2}
arms = b.translate(arms, 0, -16)
arms = b.any
{
arms,
arms =
b.any {
arms,
b.rotate(arms, degrees(120)),
b.rotate(arms, degrees(-120))
}
local frame = b.any{arms, ring}
local frame = b.any {arms, ring}
local ball = b.circle(8)
local iron = b.resource(b.circle(6), "iron-ore", value(1000, 1))
local copper = b.resource(b.circle(6), "copper-ore", value(800, 0.8))
local stone = b.resource(b.circle(4), "stone", value(500, .5))
local coal = b.resource(b.circle(6), "coal", value(600, 0.6))
local uranium = b.resource(b.circle(4), "uranium-ore", value(400, 1))
local oil = b.resource(b.throttle_world_xy(b.circle(6), 1, 4, 1, 4), "crude-oil", value(100000, 50))
local iron = b.resource(b.circle(6), 'iron-ore', value(1000, 1))
local copper = b.resource(b.circle(6), 'copper-ore', value(800, 0.8))
local stone = b.resource(b.circle(4), 'stone', value(500, .5))
local coal = b.resource(b.circle(6), 'coal', value(600, 0.6))
local uranium = b.resource(b.circle(4), 'uranium-ore', value(400, 1))
local oil = b.resource(b.throttle_world_xy(b.circle(6), 1, 4, 1, 4), 'crude-oil', value(100000, 50))
local iron_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, iron),"water-tile", "grass-1")
local copper_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, copper),"water-tile", "grass-1")
local stone_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, stone),"water-tile", "grass-1")
local coal_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, coal),"water-tile", "grass-1")
local uranium_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, uranium),"water-tile", "grass-1")
local oil_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, oil),"water-tile", "grass-1")
--[[ local iron_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, iron), 'water-tile', 'grass-1')
local copper_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, copper), 'water-tile', 'grass-1')
local stone_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, stone), 'water-tile', 'grass-1')
local coal_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, coal), 'water-tile', 'grass-1')
local uranium_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, uranium), 'water-tile', 'grass-1')
local oil_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, oil), 'water-tile', 'grass-1') ]]
local iron_ball = b.apply_entity(ball, iron)
local copper_ball = b.apply_entity(ball, copper)
local stone_ball = b.apply_entity(ball, stone)
local coal_ball = b.apply_entity(ball, coal)
local uranium_ball = b.apply_entity(ball, uranium)
local oil_ball = b.apply_entity(ball, oil)
local balls1 = b.any
{
local balls1 =
b.any {
b.translate(iron_ball, 0, -12),
b.rotate(b.translate(copper_ball, 0, -12), degrees(120)),
b.rotate(b.translate(coal_ball, 0, -12), degrees(-120)),
b.rotate(b.translate(coal_ball, 0, -12), degrees(-120)),
frame
}
--shape = b.rotate(shape, degrees(rot))
@ -61,33 +71,32 @@ balls1 = b.rotate(balls1, degrees(180))
balls1 = b.choose(outer, balls1, b.empty_shape)
balls1 = b.translate(balls1, 0, -36)
local balls2 = b.any
{
local balls2 =
b.any {
b.translate(iron_ball, 0, -12),
b.rotate(b.translate(copper_ball, 0, -12), degrees(120)),
b.rotate(b.translate(stone_ball, 0, -12), degrees(-120)),
b.rotate(b.translate(stone_ball, 0, -12), degrees(-120)),
frame
}
balls2 = b.rotate(balls2, degrees(180))
balls2 = b.choose(outer, balls2, b.empty_shape)
balls2 = b.choose(outer, balls2, b.empty_shape)
balls2 = b.translate(balls2, 0, -36)
balls2 = b.rotate(balls2, degrees(120))
local balls3 = b.any
{
local balls3 =
b.any {
b.translate(iron_ball, 0, -12),
b.rotate(b.translate(uranium_ball, 0, -12), degrees(120)),
b.rotate(b.translate(oil_ball, 0, -12), degrees(-120)),
b.rotate(b.translate(oil_ball, 0, -12), degrees(-120)),
frame
}
balls3 = b.rotate(balls3, degrees(180))
balls3 = b.choose(outer, balls3, b.empty_shape)
balls3 = b.choose(outer, balls3, b.empty_shape)
balls3 = b.translate(balls3, 0, -36)
balls3 = b.rotate(balls3, degrees(-120))
local balls4 = b.any
{
local balls4 =
b.any {
balls1,
balls2,
balls3,
@ -99,9 +108,9 @@ balls4 = b.choose(b.scale(outer, 3, 3), balls4, b.empty_shape)
local function make_ball(shape, sf)
local s1 = b.translate(shape, 0, -12 * sf)
local shape = b.any
{
s1,
local shape =
b.any {
s1,
b.rotate(s1, degrees(120)),
b.rotate(s1, degrees(-120)),
b.scale(frame, sf, sf)
@ -110,18 +119,22 @@ local function make_ball(shape, sf)
local bound = b.scale(outer, sf, sf)
return b.choose(bound, shape, b.empty_shape)
return b.choose(bound, shape, b.empty_shape)
end
local ratio = 24 / 8
local ratio = 24 / 8
local map = balls4
local total_sf = 1 * ratio * ratio
for i = 1, 6 do
map = make_ball(map, total_sf)
for i = 1, 6 do
map = make_ball(map, total_sf)
total_sf = ratio * total_sf
end
map = b.translate(map, 0, -19680)
map = b.scale(map, 1.5, 1.5)
map = b.translate(map, 0, -19669)
map = b.scale(map, 2, 2)
map = b.change_map_gen_collision_tile(map, 'water-tile', 'grass-1')
map = b.change_tile(map, false, 'water')
map = b.fish(map, 0.0025)
return map