Merge pull request #85 from Valansch/dev_island_resort

Cleanup to island resort code, elseifs and whitespace mostly.
This commit is contained in:
Valansch
2017-10-11 16:58:09 +02:00
committed by GitHub
+26 -50
View File
@@ -80,6 +80,7 @@ function run_combined_module(event)
local a = pos_y * pos_y
local b = pos_x * pos_x
local tile_distance_to_center = a + b
if tile_distance_to_center + noise_island_starting <= radsquare then
tile_to_insert = "grass"
end
@@ -89,63 +90,50 @@ function run_combined_module(event)
if noise_island_oil_and_uranium > 0.53 then
tile_to_insert = "red-desert"
end
if noise_island_oil_and_uranium < -0.53 then
elseif noise_island_oil_and_uranium < -0.53 then
tile_to_insert = "red-desert-dark"
end
if noise_island_stone_and_coal > 0.47 then
tile_to_insert = "grass-medium"
end
if noise_island_stone_and_coal < -0.47 then
elseif noise_island_stone_and_coal < -0.47 then
tile_to_insert = "grass-dry"
end
if noise_island_iron_and_copper > 0.47 then
tile_to_insert = "sand"
end
if noise_island_iron_and_copper < -0.47 then
elseif noise_island_iron_and_copper < -0.47 then
tile_to_insert = "sand-dark"
end
end
--Placement of Trees
if tile_to_insert ~= "water" then
if noise_trees > 0.1 then
if tile_to_insert ~= "water" and noise_trees > 0.1 and math.random(1,8) == 1 then
local tree = "tree-01"
if tile_to_insert == "grass" then
tree = "tree-05"
end
if tile_to_insert == "grass-dry" then
elseif tile_to_insert == "grass-dry" then
tree = "tree-02"
end
if tile_to_insert == "grass-medium" then
elseif tile_to_insert == "grass-medium" then
tree = "tree-04"
end
if tile_to_insert == "sand" then
elseif tile_to_insert == "sand" then
tree = "tree-07"
end
if tile_to_insert == "sand-dark" then
elseif tile_to_insert == "sand-dark" then
tree = "dry-hairy-tree"
end
if tile_to_insert == "red-desert" then
elseif tile_to_insert == "red-desert" then
tree = "dry-tree"
end
if tile_to_insert == "red-desert-dark" then
elseif tile_to_insert == "red-desert-dark" then
if math.random(1,3) == 1 then
tree = "red-desert-rock-huge-01"
else
tree = "red-desert-rock-big-01"
end
end
if math.random(1,8) == 1 then
if event.surface.can_place_entity {name=tree, position={pos_x,pos_y}} then
event.surface.create_entity {name=tree, position={pos_x,pos_y}}
end
end
end
end
if tile_to_insert == "sand" or tile_to_insert == "sand-dark" then
if math.random(1,200) == 1 then
@@ -153,8 +141,7 @@ function run_combined_module(event)
event.surface.create_entity {name="stone-rock", position={pos_x,pos_y}}
end
end
end
if tile_to_insert == "grass" or tile_to_insert == "grass-dry" or tile_to_insert == "grass-medium" then
elseif tile_to_insert == "grass" or tile_to_insert == "grass-dry" or tile_to_insert == "grass-medium" then
if math.random(1,2000) == 1 then
if event.surface.can_place_entity {name="stone-rock", position={pos_x,pos_y}} then
event.surface.create_entity {name="stone-rock", position={pos_x,pos_y}}
@@ -163,34 +150,26 @@ function run_combined_module(event)
end
--Placement of Decoratives
if tile_to_insert ~= "water" then
if tile_to_insert ~= "water" and math.random(1,5) == 1 then
if noise_decoratives > 0.3 then
local decorative = "green-carpet-grass"
if tile_to_insert == "grass" then
decorative = "green-pita"
end
if tile_to_insert == "grass-dry" then
elseif tile_to_insert == "grass-dry" then
decorative = "green-pita"
end
if tile_to_insert == "grass-medium" then
elseif tile_to_insert == "grass-medium" then
decorative = "green-pita"
end
if tile_to_insert == "sand" then
elseif tile_to_insert == "sand" then
decorative = "green-asterisk"
end
if tile_to_insert == "sand-dark" then
elseif tile_to_insert == "sand-dark" then
decorative = "green-asterisk"
end
if tile_to_insert == "red-desert" then
elseif tile_to_insert == "red-desert" then
decorative = "red-asterisk"
elseif tile_to_insert == "red-desert-dark" then
decorative = "red-asterisk"
end
if tile_to_insert == "red-desert-dark" then
decorative = "red-asterisk"
end
if math.random(1,5) == 1 then
table.insert(decoratives, {name=decorative, position={pos_x,pos_y}, amount=1})
end
end
if tile_to_insert == "red-desert-dark" then
if math.random(1,50) == 1 then
table.insert(decoratives, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
@@ -250,9 +229,10 @@ function run_combined_module(event)
end
end
end
noise_island_starting = noise_island_starting * 0.08
--Starting Resources
if tile_distance_to_center <= radsquare then
noise_island_starting = noise_island_starting * 0.08
if tile_distance_to_center + noise_island_starting > radsquare * 0.09 and tile_distance_to_center + noise_island_starting <= radsquare * 0.15 then
if event.surface.can_place_entity {name="stone", position={pos_x,pos_y}} then
event.surface.create_entity {name="stone", position={pos_x,pos_y}, amount=resource_amount*1.5}
@@ -282,14 +262,10 @@ function run_combined_module(event)
end
if tile_to_insert == "water" then
local a = pos_x + 1
table.insert(tiles, {name = tile_to_insert, position = {a,pos_y}})
local a = pos_y + 1
table.insert(tiles, {name = tile_to_insert, position = {pos_x,a}})
local a = pos_x - 1
table.insert(tiles, {name = tile_to_insert, position = {a,pos_y}})
local a = pos_y - 1
table.insert(tiles, {name = tile_to_insert, position = {pos_x,a}})
table.insert(tiles, {name = tile_to_insert, position = {pos_x + 1, pos_y}})
table.insert(tiles, {name = tile_to_insert, position = {pos_x, pos_y + 1}})
table.insert(tiles, {name = tile_to_insert, position = {pos_x - 1, pos_y}})
table.insert(tiles, {name = tile_to_insert, position = {pos_x, pos_y - 1}})
end
table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}})