mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
lazy chunk loading wip
This commit is contained in:
parent
ed54388343
commit
3a2ece5b0c
@ -7,7 +7,7 @@ require "score"
|
||||
|
||||
---- enable maps here ----
|
||||
|
||||
require "maps.deep_jungle"
|
||||
require "maps.endless_desert"
|
||||
|
||||
-----------------------------
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
--Factorio Cave Miner -- mewmew made this --
|
||||
--deep jungle-- mewmew made this --
|
||||
--You can use /c map_pregen() command to pre-generate the world before playing to avoid any possible microstutter while playing.--
|
||||
--Use /c spaghetti() to play without bots.
|
||||
|
||||
|
216
maps/endless_desert.lua
Normal file
216
maps/endless_desert.lua
Normal file
@ -0,0 +1,216 @@
|
||||
--endless desert-- mewmew made this --
|
||||
|
||||
local simplex_noise = require 'utils.simplex_noise'
|
||||
local event = require 'utils.event'
|
||||
|
||||
local function get_noise(name, pos)
|
||||
local seed = game.surfaces[1].map_gen_settings.seed
|
||||
local noise_seed_add = 25000
|
||||
seed = seed + noise_seed_add
|
||||
if name == 1 then
|
||||
local noise = {}
|
||||
noise[1] = simplex_noise.d2(pos.x * 0.01, pos.y * 0.01, seed)
|
||||
seed = seed + noise_seed_add
|
||||
noise[2] = simplex_noise.d2(pos.x * 0.1, pos.y * 0.1, seed)
|
||||
local noise = noise[1] + noise[2] * 0.1
|
||||
return noise
|
||||
end
|
||||
seed = seed + noise_seed_add
|
||||
seed = seed + noise_seed_add
|
||||
if name == 2 then
|
||||
local noise = {}
|
||||
noise[1] = simplex_noise.d2(pos.x * 0.01, pos.y * 0.01, seed)
|
||||
seed = seed + noise_seed_add
|
||||
noise[2] = simplex_noise.d2(pos.x * 0.1, pos.y * 0.1, seed)
|
||||
local noise = noise[1] + noise[2] * 0.1
|
||||
return noise
|
||||
end
|
||||
seed = seed + noise_seed_add
|
||||
seed = seed + noise_seed_add
|
||||
if name == 3 then
|
||||
local noise = {}
|
||||
noise[1] = simplex_noise.d2(pos.x * 0.001, pos.y * 0.001, seed)
|
||||
seed = seed + noise_seed_add
|
||||
noise[2] = simplex_noise.d2(pos.x * 0.01, pos.y * 0.01, seed)
|
||||
local noise = noise[1] + noise[2] * 0.1
|
||||
return noise
|
||||
end
|
||||
seed = seed + noise_seed_add
|
||||
seed = seed + noise_seed_add
|
||||
if name == 4 then
|
||||
local noise = {}
|
||||
noise[1] = simplex_noise.d2(pos.x * 0.01, pos.y * 0.01, seed)
|
||||
seed = seed + noise_seed_add
|
||||
noise[2] = simplex_noise.d2(pos.x * 0.1, pos.y * 0.1, seed)
|
||||
local noise = noise[1] + noise[2] * 0.2
|
||||
return noise
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_chunk_tiles(chunk_piece)
|
||||
local area = chunk_piece.area
|
||||
local surface = chunk_piece.surface
|
||||
local tiles = {}
|
||||
local entities = surface.find_entities(area)
|
||||
for _, e in pairs(entities) do
|
||||
if e.type == "tree" or e.force.name == "enemy" then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
local tile_to_insert = false
|
||||
for y = 0, 7, 1 do
|
||||
for x = 0, 7, 1 do
|
||||
local pos_x = area.left_top.x + x
|
||||
local pos_y = area.left_top.y + y
|
||||
local pos = {x = pos_x, y = pos_y}
|
||||
tile_distance_to_center = pos_x^2 + pos_y^2
|
||||
tile_to_insert = false
|
||||
--local noise_3 = get_noise(3, pos)
|
||||
if tile_to_insert == false then
|
||||
table.insert(tiles, {name = "sand-3", position = {pos_x,pos_y}})
|
||||
else
|
||||
table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}})
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles,true)
|
||||
end
|
||||
|
||||
local function generate_chunk_entities(chunk_piece)
|
||||
local area = chunk_piece.area
|
||||
local surface = chunk_piece.surface
|
||||
local enemy_building_positions = {}
|
||||
local enemy_worm_positions = {}
|
||||
local worm_raffle = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret"}
|
||||
local rock_raffle = {"sand-rock-big","sand-rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"}
|
||||
local rock_positions = {}
|
||||
local fish_positions = {}
|
||||
local rare_treasure_chest_positions = {}
|
||||
local treasure_chest_positions = {}
|
||||
local secret_shop_locations = {}
|
||||
local tree_positions = {}
|
||||
|
||||
for y = 0, 7, 1 do
|
||||
for x = 0, 7, 1 do
|
||||
local pos_x = area.left_top.x + x
|
||||
local pos_y = area.left_top.y + y
|
||||
local pos = {x = pos_x, y = pos_y}
|
||||
tile_distance_to_center = pos_x^2 + pos_y^2
|
||||
if surface.can_place_entity({name="biter-spawner", position=p}) then surface.create_entity {name="biter-spawner", position=p} end
|
||||
--local noise_3 = get_noise(3, pos)
|
||||
if tile_to_insert == false then
|
||||
table.insert(tiles, {name = "sand-3", position = {pos_x,pos_y}})
|
||||
else
|
||||
table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}})
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles,true)
|
||||
end
|
||||
|
||||
|
||||
function dump(o)
|
||||
if type(o) == 'table' then
|
||||
local s = '{ '
|
||||
for k,v in pairs(o) do
|
||||
if type(k) ~= 'number' then k = '"'..k..'"' end
|
||||
s = s .. '['..k..'] = ' .. dump(v) .. ','
|
||||
end
|
||||
return s .. '} '
|
||||
else
|
||||
return tostring(o)
|
||||
end
|
||||
end
|
||||
|
||||
--cut chunks into 8x8 pieces and fill them into global.chunk_pieces
|
||||
local function on_chunk_generated(event)
|
||||
if not global.chunk_pieces then global.chunk_pieces = {} end
|
||||
if not global.chunk_pieces_tile_index then global.chunk_pieces_tile_index = 1 end
|
||||
if not global.chunk_pieces_entity_index then global.chunk_pieces_entity_index = 1 end
|
||||
local a
|
||||
for pos_y = 0, 24, 8 do
|
||||
for pos_x = 0, 24, 8 do
|
||||
a = {
|
||||
left_top = {x = event.area.left_top.x + pos_x, y = event.area.left_top.y + pos_y},
|
||||
right_bottom = {x = event.area.left_top.x + pos_x + 8, y = event.area.left_top.y + pos_y + 8}
|
||||
}
|
||||
table.insert(global.chunk_pieces, {area = a, surface = event.surface})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not global.map_init_done then
|
||||
local map_gen_settings = {}
|
||||
map_gen_settings.water = "none"
|
||||
map_gen_settings.cliff_settings = {cliff_elevation_interval = 20, cliff_elevation_0 = 5}
|
||||
map_gen_settings.autoplace_controls = {
|
||||
["coal"] = {frequency = "very-low", size = "normal", richness = "normal"},
|
||||
["stone"] = {frequency = "very-low", size = "normal", richness = "normal"},
|
||||
["copper-ore"] = {frequency = "very-low", size = "normal", richness = "normal"},
|
||||
["iron-ore"] = {frequency = "very-low", size = "normal", richness = "normal"},
|
||||
["crude-oil"] = {frequency = "very-low", size = "normal", richness = "good"},
|
||||
["trees"] = {frequency = "normal", size = "normal", richness = "normal"},
|
||||
["enemy-base"] = {frequency = "normal", size = "normal", richness = "good"}
|
||||
}
|
||||
game.create_surface("endless_desert", map_gen_settings)
|
||||
game.forces["player"].set_spawn_position({0,0},game.surfaces["endless_desert"])
|
||||
global.map_init_done = true
|
||||
end
|
||||
local surface = game.surfaces["endless_desert"]
|
||||
if player.online_time < 5 and surface.is_chunk_generated({0,0}) then
|
||||
player.teleport(surface.find_non_colliding_position("player", {0,0}, 2, 1), "endless_desert")
|
||||
else
|
||||
player.teleport({0,0}, "endless_desert")
|
||||
end
|
||||
|
||||
if player.online_time < 10 then
|
||||
player.insert {name = 'raw-fish', count = 1}
|
||||
player.insert {name = 'iron-axe', count = 1}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function on_marked_for_deconstruction(event)
|
||||
if event.entity.name == "rock-huge" or event.entity.name == "rock-big" or event.entity.name == "sand-rock-big" or event.entity.name == "fish" or event.entity.type == "tree" then
|
||||
event.entity.cancel_deconstruction(game.players[event.player_index].force.name)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
if global.chunk_pieces[global.chunk_pieces_tile_index] then
|
||||
generate_chunk_tiles(global.chunk_pieces[global.chunk_pieces_tile_index])
|
||||
global.chunk_pieces_tile_index = global.chunk_pieces_tile_index + 1
|
||||
else
|
||||
if global.chunk_pieces[global.chunk_entity_tile_index] then
|
||||
generate_chunk_entities(global.chunk_pieces[global.chunk_pieces_tile_index])
|
||||
global.chunk_entity_tile_index = global.chunk_entity_tile_index + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function cheat_mode()
|
||||
local cheat_mode_enabed = true
|
||||
if cheat_mode_enabed == true then
|
||||
local surface = game.surfaces["endless_desert"]
|
||||
game.player.cheat_mode=true
|
||||
game.players[1].insert({name="power-armor-mk2"})
|
||||
game.players[1].insert({name="fusion-reactor-equipment", count=4})
|
||||
game.players[1].insert({name="personal-laser-defense-equipment", count=8})
|
||||
game.players[1].insert({name="rocket-launcher"})
|
||||
game.players[1].insert({name="explosive-rocket", count=200})
|
||||
game.speed = 2
|
||||
surface.daytime = 1
|
||||
game.player.force.research_all_technologies()
|
||||
game.forces["enemy"].evolution_factor = 0.2
|
||||
local chart = 300
|
||||
local surface = game.surfaces["endless_desert"]
|
||||
game.forces["player"].chart(surface, {lefttop = {x = chart*-1, y = chart*-1}, rightbottom = {x = chart, y = chart}})
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
event.add(defines.events.on_tick, on_tick)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
9
maps/test.lua
Normal file
9
maps/test.lua
Normal file
@ -0,0 +1,9 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
|
||||
game.print("Hello")
|
||||
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
@ -1,5 +1,5 @@
|
||||
local index = {
|
||||
"mqQcIlDBSSuYlsqS", "qXANKmjuRGjFRkUW", "WnujFSWDBwXtzJPX", "xdVfyDCCkjGTPkso", "blkCUwDfFaRxezkA"
|
||||
"mqQcIlDBSSuYlsqS", "qXANKmjuRGjFRkUW", "WnujFSWDBwXtzJPX", "xdVfyDCCkjGTPkso", "blkCUwDfFaRxezkA", "PEVkYcsbVwnnKWKm", "RmApKqaHBnDdjlUf"
|
||||
}
|
||||
|
||||
local data = {}
|
||||
|
23
session_data/PEVkYcsbVwnnKWKm.lua
Normal file
23
session_data/PEVkYcsbVwnnKWKm.lua
Normal file
@ -0,0 +1,23 @@
|
||||
local playsession = {
|
||||
{"mewmew", {614207}},
|
||||
{"Drezik99", {113672}},
|
||||
{"Akitae", {65389}},
|
||||
{"ANV1L", {407333}},
|
||||
{"anonieme_beer", {367781}},
|
||||
{"vvictor", {142462}},
|
||||
{"opasuke", {6222}},
|
||||
{"cinzhal", {101026}},
|
||||
{"Itai795", {362520}},
|
||||
{"Biobuur", {1294}},
|
||||
{"Catbert", {51196}},
|
||||
{"Nicky_OCD", {1202}},
|
||||
{"peterputze", {123083}},
|
||||
{"ajicurry", {2702}},
|
||||
{"Pentbot", {42522}},
|
||||
{"Fobas", {19821}},
|
||||
{"Serikai", {18416}},
|
||||
{"SpwnX", {1357}},
|
||||
{"swake", {93382}},
|
||||
{"Xonic6", {3594}}
|
||||
}
|
||||
return playsession
|
190
session_data/RmApKqaHBnDdjlUf.lua
Normal file
190
session_data/RmApKqaHBnDdjlUf.lua
Normal file
@ -0,0 +1,190 @@
|
||||
local playsession = {
|
||||
{"mewmew", {760334}},
|
||||
{"redlabel", {1458920}},
|
||||
{"ANV1L", {236969}},
|
||||
{"opasuke", {1204692}},
|
||||
{"Itai795", {303518}},
|
||||
{"anonieme_beer", {3068}},
|
||||
{"abrown4521", {339098}},
|
||||
{"maate", {1073034}},
|
||||
{"Jhumekes", {195435}},
|
||||
{"Drezik99", {87380}},
|
||||
{"legendary_banana", {10341}},
|
||||
{"Dreamon5410", {2923}},
|
||||
{"Waldlaeufer17", {38039}},
|
||||
{"Catbert", {24303}},
|
||||
{"Pentbot", {206417}},
|
||||
{"magge026", {489958}},
|
||||
{"Birdz", {1525355}},
|
||||
{"doodoori2", {3124}},
|
||||
{"MetonymicalInsanity", {343281}},
|
||||
{"sloeman", {242913}},
|
||||
{"ajicurry", {146979}},
|
||||
{"vvictor", {333060}},
|
||||
{"TheFlameWillFade", {161797}},
|
||||
{"Chmizuno", {2033}},
|
||||
{"wubwub69_", {179387}},
|
||||
{"Wernast", {94475}},
|
||||
{"lyman", {82357}},
|
||||
{"jmorris92", {8307}},
|
||||
{"shyboo72", {46422}},
|
||||
{"cinzhal", {365356}},
|
||||
{"ktrc199", {232935}},
|
||||
{"SLQ", {26287}},
|
||||
{"Eject-Master", {432002}},
|
||||
{"vedolv", {628576}},
|
||||
{"kendoctor", {2509758}},
|
||||
{"StandaardStefan", {2515991}},
|
||||
{"hobbitmax", {148090}},
|
||||
{"Biobuur", {127770}},
|
||||
{"fou_shad", {321273}},
|
||||
{"Natty", {9644}},
|
||||
{"hamer20033", {317342}},
|
||||
{"cocoilove", {5531}},
|
||||
{"ailishi19", {882119}},
|
||||
{"Headscrew", {418172}},
|
||||
{"SzubiX", {2011}},
|
||||
{"grahamm", {143356}},
|
||||
{"Irx99", {177795}},
|
||||
{"sexyflanders", {373678}},
|
||||
{"Didalus", {821118}},
|
||||
{"thaurond", {77079}},
|
||||
{"Wadiyatalkinbeet", {5741}},
|
||||
{"StarLite", {719812}},
|
||||
{"GuidoCram", {191243}},
|
||||
{"fce2", {526742}},
|
||||
{"liuqiang", {20754}},
|
||||
{"HighInFiberOptics", {3267}},
|
||||
{"kagami3287", {113183}},
|
||||
{"MtheB", {27421}},
|
||||
{"Aoti", {13068}},
|
||||
{"Methir", {34537}},
|
||||
{"Defcon_on", {15349}},
|
||||
{"Gerkiz", {192516}},
|
||||
{"whiteday2jp", {2692}},
|
||||
{"twinotter", {2271}},
|
||||
{"Cretlin", {75096}},
|
||||
{"Snowpig7u", {10757}},
|
||||
{"maxim67899", {5006}},
|
||||
{"joe32", {948813}},
|
||||
{"ZarSama", {15156}},
|
||||
{"Purgen", {5725}},
|
||||
{"xatrivus", {188121}},
|
||||
{"kostrahb", {481254}},
|
||||
{"biricov", {8835}},
|
||||
{"Tribbiani", {57314}},
|
||||
{"jordan703", {3063}},
|
||||
{"Serikai", {27711}},
|
||||
{"Fobas", {30006}},
|
||||
{"Bawz", {5081}},
|
||||
{"blesmrt", {1215923}},
|
||||
{"dangomushi", {6898}},
|
||||
{"MrTea", {113679}},
|
||||
{"Sprayl", {9618}},
|
||||
{"Ray_", {14007}},
|
||||
{"ro88ie", {3360}},
|
||||
{"Yardsnake", {5560}},
|
||||
{"VanderGraaf", {8830}},
|
||||
{"Zetsid", {29347}},
|
||||
{"porelos", {11643}},
|
||||
{"donto", {11777}},
|
||||
{"polycephaland", {2388}},
|
||||
{"ScreamreX", {79054}},
|
||||
{"Nizick1", {74372}},
|
||||
{"coreyellow1", {80619}},
|
||||
{"Lagger289", {145721}},
|
||||
{"pigwithtach", {58458}},
|
||||
{"Raijin-Kizuku", {709088}},
|
||||
{"Nikolaus3943", {41712}},
|
||||
{"Dmitry8266", {56145}},
|
||||
{"anmac1", {25061}},
|
||||
{"TheDistracted", {75109}},
|
||||
{"i-make-robots", {138253}},
|
||||
{"KingKolla", {4301}},
|
||||
{"Derfel", {13046}},
|
||||
{"robot3331", {1766}},
|
||||
{"Erdeigyilkos", {2390}},
|
||||
{"Noctrem", {138458}},
|
||||
{"meinswank", {67441}},
|
||||
{"Crypto_X", {1486}},
|
||||
{"tafyline", {11313}},
|
||||
{"Xonic6", {1343}},
|
||||
{"TheBrainMuncher", {2180}},
|
||||
{"TheWickedMaster", {8478}},
|
||||
{"Quadrum", {3919}},
|
||||
{"KubeKing", {28072}},
|
||||
{"calsmurf2904", {61579}},
|
||||
{"Kyte", {15764}},
|
||||
{"Elvarien", {18371}},
|
||||
{"Hr.Jemine", {58640}},
|
||||
{"petr4popelka", {34685}},
|
||||
{"Tordhen", {46844}},
|
||||
{"Wizard7187", {368970}},
|
||||
{"rubafix", {4249}},
|
||||
{"ZaRRiTE", {126994}},
|
||||
{"Voltar_2000", {53650}},
|
||||
{"Schallfalke", {196918}},
|
||||
{"SpaceLordBE", {43504}},
|
||||
{"Sinders", {7923}},
|
||||
{"swake", {201141}},
|
||||
{"Uhhhhh55", {61393}},
|
||||
{"Guitoune", {1219}},
|
||||
{"satanpekelnik", {25901}},
|
||||
{"Bargu", {1042197}},
|
||||
{"nameless_imp", {34586}},
|
||||
{"SandmanNL", {6078}},
|
||||
{"Eylrid", {8100}},
|
||||
{"DoxxMulder", {57316}},
|
||||
{"Sholvo", {120850}},
|
||||
{"legogo29", {153159}},
|
||||
{"luziferius", {574093}},
|
||||
{"SuperDerpWizard", {119223}},
|
||||
{"Dominoscraft", {35988}},
|
||||
{"llamaben54", {5427}},
|
||||
{"amferes", {20625}},
|
||||
{"Terarink", {728230}},
|
||||
{"zhyko", {5891}},
|
||||
{"ZombieMooose", {11994}},
|
||||
{"mobieh22", {10010}},
|
||||
{"TheThane", {10378}},
|
||||
{"BortonMichaels", {2160}},
|
||||
{"GingyGing", {32404}},
|
||||
{"Yaxley", {6492}},
|
||||
{"Kevin_Ar18", {10876}},
|
||||
{"Ardordo", {36340}},
|
||||
{"npo6ka", {14631}},
|
||||
{"Atropos89", {77881}},
|
||||
{"CreeperMillion5", {8053}},
|
||||
{"Redrar", {4297}},
|
||||
{"godfoder", {821}},
|
||||
{"AwkwardNoah", {124286}},
|
||||
{"lucj25", {28686}},
|
||||
{"dragon12129", {4528}},
|
||||
{"Alordex", {75781}},
|
||||
{"alnmike", {1304}},
|
||||
{"GordonGiraffe", {79754}},
|
||||
{"pfg", {5688}},
|
||||
{"TmgNukem", {32524}},
|
||||
{"PlumpCat", {29186}},
|
||||
{"kmarcusm", {146131}},
|
||||
{"dpoba", {677901}},
|
||||
{"LycostA", {11503}},
|
||||
{"lazerandy", {109856}},
|
||||
{"Furancebob", {371010}},
|
||||
{"Akitae", {407584}},
|
||||
{"OmegaLunch", {861}},
|
||||
{"Augster137", {15520}},
|
||||
{"I_dream_of_corn", {12323}},
|
||||
{"wengPC", {1965}},
|
||||
{"Ravengyre", {463}},
|
||||
{"Cheeseftw", {4829}},
|
||||
{"arondir", {3844}},
|
||||
{"XaLpHa1989", {19673}},
|
||||
{"Schematix", {294}},
|
||||
{"dac9", {2596}},
|
||||
{"Goofables", {3087}},
|
||||
{"chromaddict", {64987}},
|
||||
{"wolfe08", {5292}},
|
||||
{"Achskelmos", {56047}}
|
||||
}
|
||||
return playsession
|
Loading…
x
Reference in New Issue
Block a user