Hello.
First to run this lib you need instal luaGD, but you can run it on otserver but you will need O.T.A.L v 1.2.
Well this function you insert in first param the area (like spells areas)
Second param its filename with finish .png, and thidh param you insert size of each var of table.
This is an example to use:
And this is the photo:
First to run this lib you need instal luaGD, but you can run it on otserver but you will need O.T.A.L v 1.2.
Well this function you insert in first param the area (like spells areas)
Second param its filename with finish .png, and thidh param you insert size of each var of table.
Lua:
function drawnArea(area,name,pixels)
if not gd then
require('gd')
end
pixels = pixels or 1
im = gd.createTrueColor(#area[1]*pixels,#area*pixels)
local colors = {
[0] = im:colorAllocate(0xff,0xff,0xff),
[1] = im:colorAllocate(0xff,0x00,0x00),
[2] = im:colorAllocate(0x00,0xff,0x00),
[3] = im:colorAllocate(0x00,0x00,0xff),
}
for Y=1,#area do
for X=1,#area[Y] do
for px=1,pixels do
for py=1,pixels do
im:setPixel((((X*pixels)+px)-pixels-1), (((Y*pixels)+py)-pixels-1),colors[area[(Y)][(X)]])
end
end
end
end
if name:sub(name:len()-3,-1) ~= '.png' then
name = name..'.png'
end
return im:png(name)
end
Lua:
area = {
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,1,0,0,0,0},
{0,0,0,1,1,1,0,0,0},
{0,0,1,1,1,1,1,0,0},
{0,1,1,1,3,1,1,1,0},
{0,0,1,1,1,1,1,0,0},
{0,0,0,1,1,1,0,0,0},
{0,0,0,0,1,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
}
if drawnArea(area,'raposaloca.png',12) then
print('Finished')
end