credomane / FactorioMods_FactorioMaps

Jeroon's Factorio Maps mod
http://www.factorioforums.com/14582
47 stars 7 forks source link

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

Closed DanielNagy closed 6 years ago

DanielNagy commented 6 years ago

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 commented 6 years ago

*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 commented 6 years ago

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?