Custom images on maps - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: Custom images on maps (/thread-2952.html) |
Custom images on maps - Mathias - 05-18-2017 I noticed that you can change individual pixels on maps using SetPixel in cMap. I had an idea of creating a plugin (similar to Bukkit plugins) that downloads an image from the internet, resizes it to the size of a map, fetches the colors from the pixels in the image and places them on the map with SetPixel. However, I have no idea how to manipulate the image easily with Lua. Does anyone have any ideas? (Map in this case is the map item that you can hold in your hand and place) The code I have written so far. It currently only downloads the image: Code: Connect = {} RE: Custom images on maps - NiLSPACE - 05-18-2017 You'll have to decode the image so you can read the individual image. There is a pure-Lua one for PNG's: https://github.com/DelusionalLogic/pngLua RE: Custom images on maps - Seadragon91 - 05-18-2017 The code does this:
Add the code in a plugin and register the command: cPluginManager:BindCommand("/testmap", "testmap", CommandTestMap, "testmap") function CommandTestMap(a_Split, a_Player) if not(a_Player:GetInventory():HasItems(cItem(E_ITEM_MAP,1, 1))) then -- Add map a_Player:GetInventory():AddItem(cItem(E_ITEM_MAP, 1, 1)) end a_Player:GetWorld():GetMapManager():DoWithMap(1, -- damage value = item id of map function(a_Map) a_Player:SendMessage("Callback called") for x = 1, 100 do for y = 1, 100 do a_Map:SetPixel(x, y, cMap.E_BASE_COLOR_TRANSPARENT) end end end) a_Player:SendMessage("Done!") return true end RE: Custom images on maps - Seadragon91 - 05-18-2017 @Mathias Does it work for you setting the pixel and you see it then? RE: Custom images on maps - Mathias - 05-19-2017 (05-18-2017, 11:32 PM)Seadragon91 Wrote: @Mathias Does it work for you setting the pixel and you see it then? It seems like maps are not generated unless right-clicking an empty map. I can then modify the pixels, but the custom pixels are overwritten if you don't change the map scale. This code works after the map has been generated by right-clicking an empty map: Code: Player:GetWorld():GetMapManager():DoWithMap(0, RE: Custom images on maps - BillBodkin - 11-21-2019 It also seems to only work if a player is currently holding a map, im guessing map updates ore only sent to players who are holding a map. |