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:
(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 = {}
function Initialize(Plugin)
Plugin:SetName(g_PluginInfo.Name)
dofile(cPluginManager:GetPluginsPath() .. "/InfoReg.lua")
RegisterPluginInfoCommands()
LOG("Initialised " .. Plugin:GetName())
return true
end
function HandleMapImageCommand(Split, Player)
if Split[2] == nil then
Player:SendMessageInfo("Usage: " .. Split[1] .. " <imageurl>")
else
local URL = Split[2]
local FileName = URL:match("([^/]+)$")
cUrlClient:Get(Split[2],
function(Body, Data)
local Image = io.open(FileName, "wb")
Image:write(Body)
Image:close()
local Image = nil
end
)
end
return true
end
function OnDisable()
LOG("Disabled " .. cPluginManager:GetCurrentPlugin():GetName() .. "!")
end