From 1c62f974fa098bdf23e399a02a17a4e62581f5e0 Mon Sep 17 00:00:00 2001 From: Valansch Date: Tue, 18 Jul 2017 20:28:00 +0200 Subject: [PATCH] Added donut and removed module boll call from map_layout.lua --- locale/gen_shape/donut.lua | 37 +++++++++++++++++++++++++++++++++++++ map_layout.lua | 13 +++++++------ 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 locale/gen_shape/donut.lua diff --git a/locale/gen_shape/donut.lua b/locale/gen_shape/donut.lua new file mode 100644 index 00000000..2b303d20 --- /dev/null +++ b/locale/gen_shape/donut.lua @@ -0,0 +1,37 @@ +--Donut script by Neko_Baron - tested on RedMew +if shape_module then return end +shape_module = true + +--change these to mess with ring/shape +local donut_radius = 1600 +local donut_width = 128 + +--dont touch these +local donut_half = donut_width * 0.5 +local x_offset = donut_radius - donut_half +local donut_low = x_offset^2 +local donut_high = (x_offset+donut_width)^2 + + +function run_shape_module(event) + local area = event.area + local surface = event.surface + local tiles = {} + + local top_left = area.left_top --make a more direct reference + + + for x = top_left.x-1, top_left.x + 32 do + for y = top_left.y-1, top_left.y + 32 do + + local x_off = x - donut_radius + local distance = x_off^2 + y^2 -- we dont bother to get sqr of it, because we just want the cubed answer to compare to donut_low/high + if distance > donut_high or distance < donut_low then + table.insert(tiles, {name = "out-of-map", position = {x,y}}) + end + end + end + surface.set_tiles(tiles) + + return true +end \ No newline at end of file diff --git a/map_layout.lua b/map_layout.lua index 61149f00..fe381efe 100644 --- a/map_layout.lua +++ b/map_layout.lua @@ -10,10 +10,11 @@ require "locale.gen_shared.simplex_noise" --shapes-- --require "locale.gen_shape.right" --require "locale.gen_shape.up" -require "locale.gen_shape.maze" +--require "locale.gen_shape.maze" --require "locale.gen_shape.spiral" --require "locale.gen_shape.spiral_tri" --require "locale.gen_shape.spiral2" +--require "locale.gen_shape.donut" --terrain-- --require "locale.gen_terrain.neko_bridged_rivers" @@ -25,18 +26,18 @@ require "locale.gen_shape.maze" --TODO: IMPLEMENT BROKEN STYLES. DO NOT MERGE INTO MASTER BEFORE THIS IS local on_chunk_generated = function(event) - if shape_module then + if run_shape_module ~= nil then if run_shape_module(event) then - if terrain_module then + if run_terrain_module ~= nil then run_terrain_module(event) - elseif ores_module then + elseif run_ores_module ~= nil then run_ores_module(event) end end else - if terrain_module then + if run_terrain_module ~= nil then run_terrain_module(event) - elseif ores_module then + elseif run_ores_module ~= nil then run_ores_module(event) end end