Updates to json files

This commit is contained in:
Cooldude2606
2018-08-14 17:24:31 +01:00
parent 5fac283d2b
commit 0b67b8a7b5
29 changed files with 193 additions and 131 deletions

View File

@@ -1,7 +1,34 @@
-- made by cooldude
-- idea from Mylon - Dirt Path
local adjacency_boost = 10 -- makes paths more lickly to be next to each other
local adjacency_boost = 2 -- makes paths more lickly to be next to each other; must be greater than 0
local entities = {
['stone-furnace']=2,
['steel-furnace']=2,
['electric-furnace']=3,
['assembling-machine-1']=3,
['assembling-machine-2']=3,
['assembling-machine-3']=3,
['beacon']=3,
['centrifuge']=3,
['chemical-plant']=3,
['oil-refinery']=7,
['storage-tank']=3,
['nuclear-reactor']=5,
['steam-engine']=4,
['steam-turbine']=4,
['boiler']=3,
['heat-exchanger']=3,
['stone-wall']=1,
['gate']=1,
['gun-turret']=2,
['laser-turret']=2,
['radar']=3,
['lab']=3,
['big-electric-pole']=2,
['substation']=2,
['rocket-silo']=7
}
local placed_paths = {
['refined-concrete']=true,
['refined-hazard-concrete-right']=true,
@@ -14,13 +41,13 @@ local placed_paths = {
local paths = {
-- ['tile name'] = {health,convert to}
-- health is the average number of steps in hundards before it changes
['refined-concrete']={40,'concrete'},
['refined-hazard-concrete-right']={40,'hazard-concrete-right'},
['refined-hazard-concrete-left']={40,'hazard-concrete-left'},
['concrete']={30,'stone-path'},
['hazard-concrete-right']={30,'stone-path'},
['hazard-concrete-left']={30,'stone-path'},
['stone-path']={25,'world-gen'}, -- world-gen just makes it pick the last tile not placed by a player
['refined-concrete']={70,'concrete'},
['refined-hazard-concrete-right']={70,'hazard-concrete-right'},
['refined-hazard-concrete-left']={70,'hazard-concrete-left'},
['concrete']={50,'stone-path'},
['hazard-concrete-right']={50,'stone-path'},
['hazard-concrete-left']={50,'stone-path'},
['stone-path']={40,'world-gen'}, -- world-gen just makes it pick the last tile not placed by a player
['sand-1']={1,'sand-2'},
['sand-2']={3,'sand-3'},
['sand-3']={1,'red-desert-3'},
@@ -62,7 +89,7 @@ Event.register(defines.events.on_player_built_tile, function(event)
for _,old_tile in pairs(old_tiles) do
if placed_paths[old_tile.old_tile.name] or old_tile.old_tile.name == 'water' or old_tile.old_tile.name == 'deep-water' then else
if global.paths == nil then global.paths = {} end -- nil as you can set to false to disable
global.paths[global_key(surface,old_tile.position)]=old_tile.old_tile.name
global.paths[global_key(surface,old_tile.position)]=old_tile.old_tile.name -- not a mistake, this makes it have dimising returns
end
end
end)
@@ -79,15 +106,30 @@ Event.register(defines.events.on_player_changed_position, function(event)
local count = 1
for x = -1,1 do for y = -1,1 do
local _pos = {pos.x+x,pos.y+y}
if paths[tile_name][2] == 'world-gen' and not placed_paths[surface.get_tile(_pos).name]
if placed_paths[tile_name] and not placed_paths[surface.get_tile(_pos).name]
or surface.get_tile(_pos).name == paths[tile_name][2]
then chance=chance*(adjacency_boost/count) count=count+1 end
then chance=chance*((adjacency_boost+8)/count) count=count+1 end
end end
if math.random() < chance then
down_grade(surface,pos)
end
end)
Event.register(defines.events.on_built_entity, function(event)
local entity = event.entity
local surface = player.surface
if entities[entity.name] then
local size = entities[entity.name]
for (x in 0,size) do for (y in 0,size) do
local pos = [entity.position.x+x,entity.position.y+y]
local tile = surface.get_tile(pos).name
if math.random() < paths[tile]*size then
down_grade(surface,pos)
end
end end
end
end)
--[[
/interface
local tile_name = tile.name
@@ -100,4 +142,4 @@ for x = -1,1 do for y = -1,1 do
then game.print('boost '..tostring(count)) chance=chance=chance*(adjacency_boost/count) count=count+1 end end
end
return chance
]]
]]