Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spiral Mode #16

Open
ghost opened this issue Apr 20, 2017 · 6 comments
Open

Spiral Mode #16

ghost opened this issue Apr 20, 2017 · 6 comments

Comments

@ghost
Copy link

ghost commented Apr 20, 2017

Spiral config doesn't work out of the box, plus grid is present in some areas when making a spiral map.
https://i.imgur.com/Zarof0S.png

@zackman0010
Copy link
Contributor

zackman0010 commented Apr 20, 2017

With what code did you try to make a spiral?
I mean what did you attempt to change? Spiral worked last time we used it, and we haven't really changed the code since.

@zackman0010
Copy link
Contributor

You changed control.lua line 19 from 'require "locale/mapsettings/resources"' to 'require "locale/mapsettings/spiral"'?

@ghost
Copy link
Author

ghost commented Apr 20, 2017

local tau=2*math.pi
local atan2=math.atan2
local sqrt = math.sqrt
local landWidth
local gap
local function TileIsInSpiral(x,y)
	return (sqrt(x*x+y*y)+atan2(y,x)*gap/tau)%gap<landWidth
end

Event.register(defines.events.on_chunk_generated, function(event)
	landWidth = landWidth or global.scenario.config.mapsettings.spiral_land_width
	gap = landWidth + global.scenario.config.mapsettings.spiral_water_width
	local tiles = {}
	for x = event.area.left_top.x, event.area.right_bottom.x - 1 do
		for y = event.area.left_top.y, event.area.right_bottom.y - 1 do
			if not (math.abs(x) < 4 and math.abs(y) < 4) then
				if not TileIsInSpiral(x, y) then
					table.insert(tiles, {name="water", position = {x,y}})
				elseif event.surface.get_tile(x,y).name:find("water") then
					table.insert(tiles, {name="grass", position = {x,y}})
				end
			end
		end
	end
	event.surface.set_tiles(tiles)
end)

@ghost
Copy link
Author

ghost commented Apr 20, 2017

Yes. Here is my control includes:
https://i.imgur.com/2IpBfVB.png

In the latest commit; please check lines 4,5 of spiral.lua. 4 uses a variable that doesn't exist I believe, and appears both are kicking off before scenario is created.

@zackman0010
Copy link
Contributor

Those two variables are set in config.lua

@zackman0010
Copy link
Contributor

Actually.. one of them is messed up. Line 4 has config and mapsettings swapped.
'global.scenario.mapsettings.config.spiral_land_width'
should be
'global.scenario.config.mapsettings.spiral_land_width'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant