Mat Fenric Posted December 17, 2021 Report Share Posted December 17, 2021 Hello I have loaded the source code of VintageStoryAPI, VSEssentialsMod, VSCreativeMod and VSSurvivalMod to find how load a map and generate images for a web site (so, not for a mod). I know that the map is a .db file in the VintagestoryData\Maps directory It's possible to read it with the method OpenOrCreate of a MapBD object, get a MapPieceDB object with GetMapPiece method and read the Pixels int array. But I don't know how to initiate a ILogger object for the MapDB constructor. MapDB mapdb = new MapDB(logger); And I don't know yet how I will be able to read the Pixels int array to tranform the int in pixel data and generate the image. My actual attempt : string errorMessage = null; string mapdbfilepath = @"[...]\VintagestoryData\Maps\[...].db"; //? api.World.Logger - ILogger Logger MapDB mapdb = new MapDB(logger); mapdb.OpenOrCreate(mapdbfilepath, ref errorMessage, false, true, false); Vec2i coord = new Vec2i(0, 0); MapPieceDB piece = mapdb.GetMapPiece(coord); if (piece?.Pixels != null) { lblIntsMap.Text = string.Empty; foreach (int pixel in piece.Pixels) lblIntsMap.Text += pixel.ToString(); } I'm not sure how the coordinates of the Vec2i cord object work... Can you help me ? Link to comment Share on other sites More sharing options...
DArkHekRoMaNT Posted December 17, 2021 Report Share Posted December 17, 2021 20 minutes ago, Mat Fenric said: I'm not sure how the coordinates of the Vec2i cord object work... I think it takes a map for the chunk at these coordinates. Try 500_000 500_000 - this should give one of the chunks next to the spawn. The game uses absolute unsigned coordinates, which are translated into coordinates relative to the spawn for the player. Or 500_000/api.WorldManager.ChunkSize Link to comment Share on other sites More sharing options...
Mat Fenric Posted December 17, 2021 Author Report Share Posted December 17, 2021 (edited) I forgot to indicate that I am in a website (ASP.NET, C#), so I do not have access (I suppose) to an "api" object. Edited December 17, 2021 by Mat Fenric Link to comment Share on other sites More sharing options...
Mat Fenric Posted December 17, 2021 Author Report Share Posted December 17, 2021 7 minutes ago, DArkHekRoMaNT said: I think it takes a map for the chunk at these coordinates. Try 500_000 500_000 - this should give one of the chunks next to the spawn. The game uses absolute unsigned coordinates, which are translated into coordinates relative to the spawn for the player. Or 500_000/api.WorldManager.ChunkSize Good tip, thank you. Link to comment Share on other sites More sharing options...
Mat Fenric Posted December 17, 2021 Author Report Share Posted December 17, 2021 @DArkHekRoMaNTIt 's not block coordinates but chunk coordinates, so the middle is 15 625 x 15 625 (for 1 024 000 blocks by side map and 32 by side chunk). For everyone, I found a way to read the file. Now I need to know how to transform data like this into pixel color: Quote -15517387, -14515600, -14337470, -14996173, -15238566, -15574202, -15120567, -14657446, -15712449, -14915227, -15247020, -14595008, -15318210, -15909570, -15581383, -15644605, -14270390, -14858429, -15453650, -15579068, -12941203, -13470627, -13470627, -15381435, -14588327, -14785187, -15579064, -15247539, -15048360, -15445172, -14786472, -15049640 Link to comment Share on other sites More sharing options...
DArkHekRoMaNT Posted December 17, 2021 Report Share Posted December 17, 2021 (edited) 34 minutes ago, Mat Fenric said: Now I need to know how to transform data like this into pixel color: Looks like common int color. Same as hex color, but decimal Edited December 17, 2021 by DArkHekRoMaNT Link to comment Share on other sites More sharing options...
Mat Fenric Posted December 17, 2021 Author Report Share Posted December 17, 2021 3 hours ago, DArkHekRoMaNT said: Looks like common int color. Same as hex color, but decimal My actual generation versus the map in game : Link to comment Share on other sites More sharing options...
Mat Fenric Posted December 18, 2021 Author Report Share Posted December 18, 2021 Finally, I have found the solution (not the best I suppose, but it works). Left my image, right VS map. 1 Link to comment Share on other sites More sharing options...
Recommended Posts