Page 1 of 5

[0.11.x] Factorio Maps

Posted: Mon Sep 15, 2014 3:13 pm
by jeroon
As requested here

This mod creates a Google Map of your Factorio game. It will create a local html file, nothing has to be uploaded for it to work.

Usage :

- Click "Generate Images". This will start taking the screenshots, and generate an index.html in the script-output folder. Script-output is in the same folder as Saves.
- Open index.html in your browser (Double click it/Open With/Drag in browserwindow)

For info on the advanced options, click Help.

ToDo:
- Add markers to the map/ set center of map (need to figure out Google Maps pixel to Latitude)
- Make advanced stuff disappear with the click of a button ; )

Changelog:
17 nov 2014: v0.4.1
- Small change to make it work in 0.11.3
changelog older versions

Re: [0.10.x] Factorio Maps

Posted: Mon Sep 15, 2014 3:16 pm
by _aD
Easy to run and the output works flawlessly. A good way of planning long term expansion! Would purchase again A++++***

Re: [0.10.x] Factorio Maps

Posted: Mon Sep 15, 2014 3:50 pm
by cube
Image

Two minor additions into the todo list:
- Rename the zip so that it works with https://forums.factorio.com/forum/vie ... =14&t=5364 (FactorioMaps_0.0.1.zip )
- Set daytime to noon before making the screenshots and set it back afterwards.

Re: [0.10.x] Factorio Maps

Posted: Mon Sep 15, 2014 6:16 pm
by Skellitor301
You do realize you can already do this and make labeled markers in the game right?

Image

Just place a single track and put down a trainstop next to it, then remove the track, and finally rename the stop.

Re: [0.10.x] Factorio Maps

Posted: Mon Sep 15, 2014 6:20 pm
by jeroon
Skellitor301 wrote:You do realize you can already do this and make labeled markers in the game right?

Just place a single track and put down a trainstop next to it, then remove the track, and finally rename the stop.
You posted this in the original thread as well, and I didn't understand what you meant then, and I still don't :D What does that do?

Re: [0.10.x] Factorio Maps

Posted: Mon Sep 15, 2014 6:34 pm
by Skellitor301
Train Stops can be renamed, and the names will show up in both the minimap and the full map at the location. I've used them to label my bases and sites

basically the same as the google maps api with labled locations, just vanilla

Re: [0.10.x] Factorio Maps

Posted: Mon Sep 15, 2014 6:36 pm
by jeroon
Skellitor301 wrote:Train Stops can be renamed, and the names will show up in both the minimap and the full map at the location. I've used them to label my bases and sites
I see. But this mod takes screenshots, it doesn't use the map or the minimap.

Re: [0.10.x] Factorio Maps

Posted: Mon Sep 15, 2014 6:39 pm
by Skellitor301
I use screenshooter for things like that, been using it for years. But yea, just wanted to point out the same thing can be achieved in vanilla

Re: [0.10.x] Factorio Maps

Posted: Mon Sep 15, 2014 6:44 pm
by Kane
Works! Here is an example :)
http://stonelegion.com/kane/Map2/

Re: [0.10.x] Factorio Maps

Posted: Mon Sep 15, 2014 11:54 pm
by micomico
Awesome mod. Works really well.

It's a pity that the screenshot function doesn't capture the Alt info.

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 2:01 am
by Kane
micomico wrote:Awesome mod. Works really well.

It's a pity that the screenshot function doesn't capture the Alt info.
I think he might be able to add that as the screenshot function if I recall has the ability to set true for gui.

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 3:33 am
by DaCyclops
Wow, Nicely Done! A pity it cant (currently) show the Alt overlay information, but if you turn it on always it does show F4 Debug information.

EDIT: sniped while I was typing :P
The built in Screenshot feature can capture the Alt information as part of the GUI, but then it would get the entire GUI. From my knowledge of how the google maps custom maps API works, turning that on would break how he currently generates it so fast without an external app. unless they update the function to allow Alt info without full GUI....

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 8:39 am
by cube
If you change extensions from png to jpg, the file size and saving time both drop about 10 times :-)

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 9:43 am
by jeroon
cube wrote:If you change extensions from png to jpg, the file size and saving time both drop about 10 times :-)
Oh wow, I was about to test that, but I never realized the difference was that big. The next version will use jpg, and once I figure out how to zoom in past the current min/max level, I might add an option to do the maps in .png. I don't think you do only the max zoom level in png, and the rest in jpg, because you have to specify the format in the index.html

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 10:13 am
by Devcod
jeroon wrote:I don't think you do only the max zoom level in png, and the rest in jpg, because you have to specify the format in the index.html
You can use if statement in JavaScript part of index.html to load files based on zoom level.
This should theoretically work, but I can't test it right now:

Code: Select all

CustomMapType.prototype.getTile = function(coord, zoom, ownerDocument) {
    var div = ownerDocument.createElement('DIV');
    var baseURL = 'Images/';
    var ext = "";
    if (zoom === CustomMapType.prototype.maxZoom) {
        ext = "png";
    } else {
        ext = "jpg";
    }
    baseURL += zoom + '_' + coord.x + '_' + coord.y + '.' + ext;
    div.style.width = this.tileSize.width + 'px';
    div.style.height = this.tileSize.height + 'px';
    div.style.backgroundColor = '#1B2D33';
    div.style.backgroundImage = 'url(' + baseURL + ')';
    return div;
};
If statement, that I added, should change ext variable to png if zoom level is same as maxzoom level. If it is not, then it is set to jpg.

Edit:

Code: Select all

center: new google.maps.LatLng(-15.07,-20.08)
I think that 0,0 would be better :)

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 10:39 am
by Phillip_Lynx
Devcod wrote:..Edit:

Code: Select all

center: new google.maps.LatLng(-15.07,-20.08)
I think that 0,0 would be better :)
Maybe centered on Player position at start??

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 10:55 am
by Devcod
Phillip_Lynx wrote:Maybe centered on Player position at start??
Setting it to 0,0 will give more consistency in case of map update (player position may change, 0,0 should always be in same place).

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 1:17 pm
by jeroon
cube wrote:- Set daytime to noon before making the screenshots and set it back afterwards.
I'm running into something weird here:

using (just a test)

Code: Select all

game.onload(function()
	game.daytime = 0
	game.takescreenshot{}
end)
works like I expect, taking a screenshot in broad daylight. When I change it to

Code: Select all

game.onload(function()
	game.daytime = 0
	game.takescreenshot{}
	game.daytime = .5
end)
It takes a screenshot in the dark. I've seen this before, where it printed info to the screen before it completed taking all screenshots. Does it complete all code before it starts taking screenshots perhaps?
Phillip_Lynx wrote:Maybe centered on Player position at start??
I'll try to make an option, Player position or center. But 0,0 is not the center unfortunately :D

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 1:38 pm
by Devcod
jeroon wrote: using (just a test)

Code: Select all

game.onload(function()
	game.daytime = 0
	game.takescreenshot{}
end)
works like I expect, taking a screenshot in broad daylight. When I change it to

Code: Select all

game.onload(function()
	game.daytime = 0
	game.takescreenshot{}
	game.daytime = .5
end)
It takes a screenshot in the dark. I've seen this before, where it printed info to the screen before it completed taking all screenshots. Does it complete all code before it starts taking screenshots perhaps?
Maybe instead use game.alwaysday ? Here you have information about it: https://forums.factorio.com/wiki/inde ... #alwaysday

Re: [0.10.x] Factorio Maps

Posted: Tue Sep 16, 2014 1:54 pm
by cube
takescreenshot only creates a request and requests are processed after everything in the current tick updates.