From 7a6787356abee84d1db384307b18b686899a75a9 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Tue, 5 Sep 2023 20:41:17 +0200 Subject: [PATCH 1/2] Scrap towny updates --- .gitignore | 2 + maps/scrap_towny_ffa/nauvis.lua | 7 ++- .../scrap_towny_ffa_layout.lua | 52 ++++++++++++++----- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 0eaf411d..07b0f0e0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ maps/biter_battles_v3/ #==Mac ignores== # General .DS_Store + +todo/ diff --git a/maps/scrap_towny_ffa/nauvis.lua b/maps/scrap_towny_ffa/nauvis.lua index 2ba3de1b..2235aa8a 100644 --- a/maps/scrap_towny_ffa/nauvis.lua +++ b/maps/scrap_towny_ffa/nauvis.lua @@ -11,8 +11,8 @@ local dataset_key = 'scrap_towny_ffa' local Public = {} -local map_width = 2560 -local map_height = 2560 +local map_width = 3840 +local map_height = 3840 local set_victory_length_token = Token.register( @@ -143,7 +143,7 @@ function Public.initialize() mgs.water = 0.5 mgs.peaceful_mode = false mgs.starting_area = 'none' - mgs.terrain_segmentation = 3 + mgs.terrain_segmentation = 3.5 -- terrain size is 64 x 64 chunks, water size is 80 x 80 mgs.width = map_width mgs.height = map_height @@ -166,7 +166,6 @@ function Public.initialize() } mgs.seed = math_random(100000, 9999999) - log(serpent.block(mgs)) if not this.active_surface_index then this.active_surface_index = game.create_surface('towny', mgs).index else diff --git a/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua b/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua index 6aacd7c7..cc590b44 100644 --- a/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua +++ b/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua @@ -8,6 +8,21 @@ local math_random = math.random local math_floor = math.floor local math_abs = math.abs +local start_ground_tiles = { + 'grass-1', + 'grass-1', + 'grass-2', + 'sand-2', + 'grass-1', + 'grass-4', + 'sand-2', + 'grass-3', + 'grass-4', + 'grass-2', + 'sand-3', + 'grass-4' +} + local scrap_entities = { -- simple entity with owner {name = 'crash-site-spaceship-wreck-small-1'}, -- these do not have mining animation @@ -281,6 +296,28 @@ local function on_chunk_generated(event) local position local noise + for x = 0, 31, 1 do + for y = 0, 31, 1 do + position = {x = left_top_x + x, y = left_top_y + y} + if math_random(1, 3) > 1 then + local tile = surface.get_tile(position) + if not tile.collides_with('water-tile') then + noise = get_noise('dungeon_sewer', position, seed) + local index = math_floor(noise * 32) % 11 + 1 + surface.set_tiles({{name = start_ground_tiles[index], position = position}}, true) + end + end + if math_random(1, 3) > 1 then + if not surface.get_tile(position).collides_with('resource-layer') then + noise = get_noise('scrap_towny_ffa', position, seed) + if is_scrap_area(noise) then + place_scrap(surface, position) + end + end + end + end + end + local chunk_position = event.position --log('chunk_position = {' .. chunk_position.x .. ',' .. chunk_position.y .. '}') if chunk_position.x >= -33 and chunk_position.x <= 32 and chunk_position.y >= -33 and chunk_position.y <= 32 then @@ -299,6 +336,7 @@ local function on_chunk_generated(event) return end end + if chunk_position.x < -33 or chunk_position.x > 32 or chunk_position.y < -33 or chunk_position.y > 32 then local area = {{x = left_top_x, y = left_top_y}, {x = left_top_x + 31, y = left_top_y + 31}} local entities = surface.find_entities(area) @@ -314,20 +352,6 @@ local function on_chunk_generated(event) return end - for x = 0, 31, 1 do - for y = 0, 31, 1 do - if math_random(1, 3) > 1 then - position = {x = left_top_x + x, y = left_top_y + y} - if not surface.get_tile(position).collides_with('resource-layer') then - noise = get_noise('scrap_towny_ffa', position, seed) - if is_scrap_area(noise) then - surface.set_tiles({{name = 'dirt-' .. math_floor(math_abs(noise) * 6) % 6 + 2, position = position}}, true) - place_scrap(surface, position) - end - end - end - end - end move_away_biteys(surface, event.area) --this.chunk_generated[key] = true end From 28c1a89aea57737e2bf41e1451feda450979468c Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Tue, 5 Sep 2023 20:42:08 +0200 Subject: [PATCH 2/2] Luacheck fix --- maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua b/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua index cc590b44..b2e0a060 100644 --- a/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua +++ b/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua @@ -6,7 +6,6 @@ local Scrap = require 'maps.scrap_towny_ffa.scrap' local table_insert = table.insert local math_random = math.random local math_floor = math.floor -local math_abs = math.abs local start_ground_tiles = { 'grass-1',