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

Incorrect Maths to determine Total Width and Total Height in generateMap.lua #19

Closed
DanielNagy opened this issue Feb 4, 2018 · 2 comments

Comments

@DanielNagy
Copy link

Using Top Left X/Y of -377, -6145 and Bottom Right X/Y of 0, -5700 as an example, your maths concludes the variables inGameTotalWidth of 377, and inGameTotalHeigh of 11845.
The correct results should be 377, and 445.
You have to Minus the Bottom Right X/Y from Top Left X/Y to find out the width / height.

I've tested, and updated my local generateMap.lua to the following to reflect the fix required instead.

local inGameTotalWidth = math.ceil(data.bottomRight.x - data.topLeft.x)
local inGameTotalHeight = math.ceil(data.bottomRight.y - data.topLeft.y)

Also, to stop the FILE NOT FOUND messages due to missing jpg layer files, i've also updated the following lines. Please note, I have only tested with "Huge" grid size setting.
As you zoom in however, it crops the edges off (still has the zoom level detail based on your Top Left / Bottom right co-ords)

--for y = 0, numVScreenshots - 1 do
to
for y = -1, numVScreenshots do

and

--for x = 0, numHScreenshots - 1 do
to
for x = -1, numHScreenshots do

@credomane
Copy link
Owner

*Scratches head*

What in the world was I thinking with the total width and total height. That is obviously wrong. It would only work when one number is positive and the other is negative. I need to update stdlib and take advantage of all the area functions that were introduced after I wrote this code originally. The included stdlib is ancient and somewhere between 0.5.0-0.6.0 releases if memory serves me. So many things added since then.

@credomane
Copy link
Owner

Fixed in FactorioMaps 0.16.1. Will release it on mod portal later once I test a bit more. Grab it from here if you want it now.

Not sure what these FILE NOT FOUND messages are about. Did these happen so show up after you made the changes to calculating the inGameTotalWidth and inGameTotalHeight?

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

2 participants