mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
Current status, messing with decoratives
This commit is contained in:
parent
1802153657
commit
4c3a7779ce
@ -125,7 +125,6 @@ function picture_builder(pic)
|
||||
-- the plus one is because lua tables are one based.
|
||||
local half_width = math.floor(width / 2) + 1
|
||||
local half_height = math.floor(height / 2) + 1
|
||||
|
||||
return function(x, y)
|
||||
x = math.floor(x)
|
||||
y = math.floor(y)
|
||||
@ -133,12 +132,7 @@ function picture_builder(pic)
|
||||
local y2 = y + half_height
|
||||
|
||||
if y2 > 0 and y2 <= height and x2 > 0 and x2 <= width then
|
||||
local pixel = "out-of-map"
|
||||
if data[y2] ~= nil then
|
||||
if data[y2][x2] ~= nil then
|
||||
pixel = data[y2][x2]
|
||||
end
|
||||
end
|
||||
local pixel = data[y2][x2]
|
||||
return pixel
|
||||
else
|
||||
return false
|
||||
|
@ -1,23 +1,24 @@
|
||||
local tile_types = {
|
||||
"hazard-concrete-left",
|
||||
"concrete",
|
||||
"stone-path",
|
||||
"hazard-concrete-right",
|
||||
"lab-dark-1",
|
||||
"deepwater",
|
||||
"deepwater-green",
|
||||
"dirt",
|
||||
"dirt-dark",
|
||||
"grass",
|
||||
"grass-medium",
|
||||
"grass-dry",
|
||||
"dirt",
|
||||
"dirt-dark",
|
||||
"hazard-concrete-left",
|
||||
"hazard-concrete-right",
|
||||
"lab-dark-1",
|
||||
"lab-dark-2",
|
||||
"red-desert",
|
||||
"red-desert-dark",
|
||||
"sand",
|
||||
"sand-dark",
|
||||
"lab-dark-2",
|
||||
"stone-path",
|
||||
"water",
|
||||
"deepwater",
|
||||
"water-green",
|
||||
"deepwater-green",
|
||||
"out-of-map",
|
||||
}
|
||||
local cols = 5
|
||||
|
@ -15,30 +15,35 @@ function run_place_tiles(params)
|
||||
surface.set_tiles(global._tiles_hold, true)
|
||||
end
|
||||
|
||||
if MAP_GEN == nil then
|
||||
game.print("MAP_GEN not set")
|
||||
return
|
||||
function run_init(params)
|
||||
global._tiles_hold = {}
|
||||
global._decoratives_hold = {}
|
||||
global._entities_hold = {}
|
||||
end
|
||||
|
||||
function run_place_tiles(params)
|
||||
local surface = params.surface
|
||||
surface.set_tiles(global._tiles_hold)
|
||||
end
|
||||
|
||||
function run_place_items(params)
|
||||
local surface = params.surface
|
||||
for _,deco in pairs(global._decoratives_hold) do
|
||||
surface.create_decoratives{check_collision=false, decoratives={deco}}
|
||||
end
|
||||
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
MAP_GEN_SURFACE = surface
|
||||
local tiles = {}
|
||||
local entities = {}
|
||||
local decoratives = {}
|
||||
|
||||
local top_x = area.left_top.x
|
||||
local top_y = area.left_top.y
|
||||
|
||||
if map_gen_decoratives then
|
||||
for _, e in pairs(surface.find_entities_filtered{area=area, type="simple-entity"}) do
|
||||
e.destroy()
|
||||
end
|
||||
for _, e in pairs(surface.find_entities_filtered{area=area, type="tree"}) do
|
||||
e.destroy()
|
||||
for _,deco in pairs(global._decoratives_hold) do
|
||||
surface.create_decoratives{check_collision=false, decoratives={deco}}
|
||||
end
|
||||
for _, entity in ipairs(global._entities_hold) do
|
||||
if surface.can_place_entity {name=entity.name, position=entity.position} then
|
||||
surface.create_entity {name=entity.name, position=entity.position}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function run_calc_items(params)
|
||||
local top_x = params.top_x
|
||||
local top_y = params.top_y
|
||||
|
||||
for y = top_y, top_y + 31 do
|
||||
for x = top_x, top_x + 31 do
|
||||
@ -91,6 +96,42 @@ function run_chart_update(params)
|
||||
-- Don't use full area, otherwise adjacent chunks get charted
|
||||
game.forces.player.chart(params.surface, {{ params.area.left_top.x, params.area.left_top.y}, { params.area.left_top.x+30, params.area.left_top.y+30} } )
|
||||
end
|
||||
end
|
||||
|
||||
function run_combined_module(event)
|
||||
|
||||
if MAP_GEN == nil then
|
||||
game.print("MAP_GEN not set")
|
||||
return
|
||||
end
|
||||
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
MAP_GEN_SURFACE = surface
|
||||
|
||||
|
||||
local top_x = area.left_top.x
|
||||
local top_y = area.left_top.y
|
||||
|
||||
if map_gen_decoratives then
|
||||
for _, e in pairs(surface.find_entities_filtered{area=area, type="decorative"}) do
|
||||
e.destroy()
|
||||
end
|
||||
for _, e in pairs(surface.find_entities_filtered{area=area, type="tree"}) do
|
||||
e.destroy()
|
||||
end
|
||||
for _, e in pairs(surface.find_entities_filtered{area=area, type="simple-entity"}) do
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
Thread.queue_action("run_init", {} )
|
||||
|
||||
Thread.queue_action("run_calc_items", {surface = event.surface, top_x = top_x, top_y = top_y})
|
||||
|
||||
Thread.queue_action("run_place_tiles", {surface = event.surface})
|
||||
Thread.queue_action("run_place_items", {surface = event.surface})
|
||||
Thread.queue_action("run_chart_update", {area = event.area, surface = event.surface} )
|
||||
|
||||
end
|
||||
|
||||
@ -109,15 +150,46 @@ local decorative_options = {
|
||||
{"green-asterisk", 25},
|
||||
{"green-bush-mini", 7},
|
||||
},
|
||||
["grass-dry"] = {},
|
||||
["grass-medium"] = {},
|
||||
["grass-medium"] = {
|
||||
{"green-carpet-grass", 12},
|
||||
{"green-hairy-grass", 28},
|
||||
{"green-bush-mini", 40},
|
||||
{"green-pita", 24},
|
||||
{"green-small-grass", 48},
|
||||
{"green-asterisk", 100},
|
||||
{"green-bush-mini", 28},
|
||||
},
|
||||
["grass-dry"] = {
|
||||
{"green-carpet-grass", 24},
|
||||
{"green-hairy-grass", 56},
|
||||
{"green-bush-mini", 80},
|
||||
{"green-pita", 48},
|
||||
{"green-small-grass", 96},
|
||||
{"green-asterisk", 200},
|
||||
{"green-bush-mini", 56},
|
||||
},
|
||||
["hazard-concrete-left"] = {},
|
||||
["hazard-concrete-right"] = {},
|
||||
["lab-dark-1"] = {},
|
||||
["lab-dark-2"] = {},
|
||||
["red-desert"] = {},
|
||||
["red-desert-dark"] = {},
|
||||
["sand"] = {},
|
||||
["red-desert"] = {
|
||||
{"brown-carpet-grass", 35},
|
||||
{"orange-coral-mini", 45},
|
||||
{"red-asterisk", 45},
|
||||
{"red-desert-bush", 12},
|
||||
{"red-desert-rock-medium", 375},
|
||||
{"red-desert-rock-small", 200},
|
||||
{"red-desert-rock-tiny", 30},
|
||||
},
|
||||
["red-desert-dark"] = {
|
||||
{"brown-carpet-grass", 70},
|
||||
{"orange-coral-mini", 90},
|
||||
{"red-asterisk", 90},
|
||||
{"red-desert-bush", 35},
|
||||
{"red-desert-rock-medium", 375},
|
||||
{"red-desert-rock-small", 200},
|
||||
{"red-desert-rock-tiny", 150},
|
||||
},
|
||||
["sand-dark"] = {},
|
||||
["stone-path"] = {},
|
||||
["water"] = {},
|
||||
@ -160,8 +232,30 @@ local entity_options = {
|
||||
["hazard-concrete-right"] = {},
|
||||
["lab-dark-1"] = {},
|
||||
["lab-dark-2"] = {},
|
||||
["red-desert"] = {},
|
||||
["red-desert-dark"] = {},
|
||||
["red-desert"] = {
|
||||
{"dry-tree", 400},
|
||||
{"dry-hairy-tree", 400},
|
||||
{"tree-06", 500},
|
||||
{"tree-06", 500},
|
||||
{"tree-01", 500},
|
||||
{"tree-02", 500},
|
||||
{"tree-03", 500},
|
||||
{"red-desert-rock-big-01", 200},
|
||||
{"red-desert-rock-huge-01", 400},
|
||||
{"red-desert-rock-huge-02", 400},
|
||||
},
|
||||
["red-desert-dark"] = {
|
||||
{"dry-tree", 400},
|
||||
{"dry-hairy-tree", 400},
|
||||
{"tree-06", 500},
|
||||
{"tree-06", 500},
|
||||
{"tree-01", 500},
|
||||
{"tree-02", 500},
|
||||
{"tree-03", 500},
|
||||
{"red-desert-rock-big-01", 200},
|
||||
{"red-desert-rock-huge-01", 400},
|
||||
{"red-desert-rock-huge-02", 400},
|
||||
},
|
||||
["sand"] = {},
|
||||
["sand-dark"] = {},
|
||||
["stone-path"] = {},
|
||||
|
Loading…
x
Reference in New Issue
Block a user