1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00

added rectangular_spiral.lua

This commit is contained in:
Valansch 2017-07-20 23:22:09 +02:00
parent 1f7364803c
commit a1309438e5
5 changed files with 96 additions and 12 deletions

View File

@ -1,3 +1,5 @@
require "locale.gen_shared.chunk_utils"
local wall_thickness = 1
local cell_size = 3 --must be an uneven number
@ -139,17 +141,6 @@ function init()
render()
end
local function removeChunk(event)
local surface = event.surface
local tiles = {}
for x = event.area.left_top.x, event.area.right_bottom.x do
for y = event.area.left_top.y, event.area.right_bottom.y do
table.insert(tiles, {name = "out-of-map", position = {x,y}})
end
end
surface.set_tiles(tiles)
end
first = true
function run_shape_module(event)

View File

@ -0,0 +1,45 @@
require "locale.gen_shared.compass"
require "locale.gen_shared.chunk_utils"
local compass = Compass.new()
local pixels={}
pixels["-1,-1"] = true
width = 4
function build()
local p = {-1,-1}
local n = 1
for x=1,300 do
for i = 1, n do
p[1] = p[1] + compass:get_direction()["x"]
p[2] = p[2] + compass:get_direction()["y"]
add(p)
end
compass:turn_left()
n = n + 1
end
end
local function onshape(p)
x = math.floor(p[1]/32/width)
y = math.floor(p[2]/32/width)
if pixels[x .. "," .. y] ~= nil then
end
return pixels[x .. "," .. y] ~= nil
end
function add(p)
pixels[p[1].. "," .. p[2]] = true
end
build()
function run_shape_module(event)
if not onshape({event.area.left_top.x - width/2 * 32,event.area.left_top.y - width/2 * 32}) then
removeChunk(event)
return false
end
end

View File

@ -0,0 +1,32 @@
--Author Valansch
Compass = {}
Compass.__index = Compass
Compass.north={x=0,y=-1,next="west"}
Compass.west={x=-1,y=0,next="south"}
Compass.south={x=0,y=1,next="east"}
Compass.east={x=1,y=0,next="north"}
function Compass.new(start_direction)
local self = setmetatable({}, Compass)
self.direction = start_direction or "north"
return self
end
function Compass:turn_left()
self.direction= self:get_direction().next
end
function Compass:get_direction()
return self[self.direction]
end
function Compass:turn_right()
self:turn()
self:turn()
self:turn()
end
function Compass:turn_around()
self:turn()
self:turn()
end

View File

@ -0,0 +1,10 @@
function removeChunk(event)
local surface = event.surface
local tiles = {}
for x = event.area.left_top.x, event.area.right_bottom.x do
for y = event.area.left_top.y, event.area.right_bottom.y do
table.insert(tiles, {name = "out-of-map", position = {x,y}})
end
end
surface.set_tiles(tiles)
end

View File

@ -1,5 +1,8 @@
--[[
Neko Does stuff to key files because Im a derp
This file is used to choose which styles you want.
You may choose up to one of each type shapes, terrain, ores and misc by removing uncommenting the line.
If you want to add your own module, just add it to the others
in this file and your run_*type*_module(event) function will be called.
--]]
@ -11,6 +14,9 @@ Neko Does stuff to key files because Im a derp
--require "locale.gen_shape.spiral_tri"
--require "locale.gen_shape.spiral2"
--require "locale.gen_shape.donut"
--require "locale.gen_shape.rectangular_spiral"
--terrain--
--require "locale.gen_terrain.neko_bridged_rivers"