1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-16 10:19:27 +02:00
RedMew/map_gen/maps/goats_on_goats.lua

120 lines
3.9 KiB
Lua
Raw Normal View History

2018-05-08 22:23:07 +02:00
local b = require "map_gen.shared.builders"
2018-01-24 21:52:40 +02:00
local pic = require "map_gen.data.presets.goat"
pic = b.decompress(pic)
2018-11-21 15:42:39 +02:00
local goat1 = b.picture(pic)
2018-05-08 22:23:07 +02:00
goat1 = b.invert(goat1)
local crop = b.rectangle(pic.width, pic.height)
goat1 = b.all{goat1, crop}
2018-01-24 21:52:40 +02:00
2018-05-08 22:23:07 +02:00
local floor = b.translate(b.rectangle(pic.width, 32), 0 , (pic.height / 2) + 12)
2018-01-24 21:52:40 +02:00
local goats = { floor, goat1 }
2018-11-21 15:42:39 +02:00
local sf = 0.75
2018-01-24 21:52:40 +02:00
local tf = 0.7
local s = 1
2018-11-21 15:42:39 +02:00
local t = 0
2018-01-24 21:52:40 +02:00
for i = 1, 5 do
s = s * sf
t = t + (s * tf * pic.height)
2018-05-08 22:23:07 +02:00
local goat = b.translate(b.scale(goat1, s, s), 0, -t)
2018-11-21 15:42:39 +02:00
table.insert( goats, goat )
2018-01-24 21:52:40 +02:00
end
2018-05-08 22:23:07 +02:00
local ceiling = b.translate(b.rectangle(pic.width, 32), 0 , -t - 32)
2018-11-21 15:42:39 +02:00
table.insert( goats, ceiling )
2018-01-24 21:52:40 +02:00
2018-05-08 22:23:07 +02:00
local shape = b.translate(b.any(goats), 0, (t / 2) - 60)
2018-01-24 21:52:40 +02:00
-- for custom goat ores
--[[
local function rot(table)
local len = #table
2018-11-21 15:42:39 +02:00
local copy = {}
2018-01-24 21:52:40 +02:00
for i = 1, len -1 do
2018-11-21 15:42:39 +02:00
copy[i+1] = table[i]
2018-01-24 21:52:40 +02:00
end
copy[1] = table[len]
return copy
end
2018-05-08 22:23:07 +02:00
local patch = b.flip_x(goat1)
--patch = b.throttle_xy(patch, 1, 2, 1 ,2)
local iron_patch = b.resource(b.scale(patch,0.12,0.12), "iron-ore", function(x,y) return 500 end)
local copper_patch = b.resource(b.scale(patch,0.12,0.12), "copper-ore", function(x,y) return 500 end)
local coal_patch = b.resource(b.scale(patch,0.12,0.12), "coal", function(x,y) return 500 end)
local stone_patch = b.resource(b.scale(patch,0.12,0.12), "stone", function(x,y) return 500 end)
local uraniumn_patch = b.resource(b.scale(patch,0.12,0.12), "uraniumn-ore", function(x,y) return 500 end)
local oil_patch = b.resource(b.scale(patch,0.12,0.12), "crude-oil", function(x,y) return 500 end)
local patch1 = b.translate(b.scale(patch,0.2,0.2),0,170)
local patch2 = b.translate(b.scale(patch,0.15,0.15),0,25)
local patch3 = b.translate(b.scale(patch,0.12,0.12),0,-88)
local patch4 = b.translate(b.scale(patch,0.1,0.1),0,-173)
local patch5 = b.translate(b.scale(patch,0.08,0.08),0,-238)
local patch6 = b.translate(b.scale(patch,0.04,0.04),0,-282)
2018-01-24 21:52:40 +02:00
local patch_table = { patch1, patch2, patch3, patch4, patch5, patch6 }
local function do_nothing(builder, x, y) return builder(x, y) end
2018-11-21 15:42:39 +02:00
local function throttle(builder, x, y)
if x % 4 < 1 and y % 4 < 1 then
return builder(x, y)
2018-01-24 21:52:40 +02:00
else
return false
end
end
2018-11-21 15:42:39 +02:00
local function linear(base, mult)
2018-01-24 21:52:40 +02:00
return function(x, y)
return base + (math.abs(x) + math.abs(y)) * mult
end
end
local res1 = {do_nothing, "iron-ore", linear(500, 1) }
local res2 = {do_nothing,"copper-ore", linear(400, 0.8) }
local res3 = {do_nothing,"coal", linear(400, 0.7) }
local res4 = {do_nothing,"stone", linear(200, 0.6) }
local res5 = {do_nothing,"uranium-ore", linear(50, 0.1) }
2018-11-21 15:42:39 +02:00
local res6 = {throttle, "crude-oil", linear(18750, 300) }
2018-01-24 21:52:40 +02:00
local res_table = { res2, res3, res4, res5, res6, res1 }
2018-11-21 15:42:39 +02:00
local res_tables = {}
for i = 1, 6 do
2018-01-24 21:52:40 +02:00
table.insert(res_tables, res_table)
res_table = rot(res_table)
end
local function res_builder(x, y, world_x, world_y)
2018-11-21 15:42:39 +02:00
local col_pos = math.floor(world_x / ISLAND_X_DISTANCE + 0.5)
2018-01-24 21:52:40 +02:00
local row_pos = math.floor(world_y / ISLAND_Y_DISTANCE + 0.5)
local offset = ((math.abs(col_pos) + math.abs(row_pos)) % 6) + 1
local rt = res_tables[offset]
for k, v in ipairs(patch_table) do
local r = rt[k]
local f = r[1]
local name = r[2]
local amount = r[3]
2018-11-21 15:42:39 +02:00
if f(v,x,y) then
2018-01-24 21:52:40 +02:00
return name, amount(world_x, world_y)
end
end
end
2018-05-08 22:23:07 +02:00
--local patches = b.any(patch_table)
--local iron = b.resource(patches,"iron-ore", function(x,y) return 400 end)
--local iron_goat = b.apply_entity(shape, iron)
local res_goat = b.apply_entity(shape, res_builder)
2018-01-24 21:52:40 +02:00
shape = res_goat
--]]
2018-05-08 22:23:07 +02:00
local shape2 = b.flip_x(shape)
local shape3 = b.flip_y(shape)
2018-11-21 15:42:39 +02:00
local shape4 = b.flip_y(shape2)
2018-01-24 21:52:40 +02:00
local pattern =
{
{shape, shape2},
{shape3, shape4},
2018-11-21 15:42:39 +02:00
}
2018-01-24 21:52:40 +02:00
2018-05-08 22:23:07 +02:00
local map = b.grid_pattern(pattern, 2, 2, pic.width, pic.height + t - 105)
map = b.change_map_gen_collision_tile(map,"water-tile", "water-green")
2018-01-24 21:52:40 +02:00
return map