• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Unless function - drawnArea

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
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.
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
This is an example to use:
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
And this is the photo:
raposaloca.png
 
Another unless function ;D
Lua:
function randPhoto()
	if not gd then
		require('gd')
	end
	im = gd.createTrueColor(100,100)
	math.randomseed(os.time())
	for x=0,100 do
	   for y=0,100 do
	   if math.random(1,10) > 6 then
	   im:setPixel(x, y,math.random(0,im:colorAllocate(0xff,0xff,0xff)))
	   end
	   end
	end
	return im:png("rand photo.png")
end
It creates:
randphoto.png
 
Why the fuck are you posting these useless functions? I know kids are masturbing on your scripts but why? Omg it's fucking useless.
 
Why the fuck are you posting these useless functions? I know kids are masturbing on your scripts but why? Omg it's fucking useless.

He already stated himself that the functions are useless, so why bother posting that useless comment? And, no function is useless. Maybe they have no practical use, but people can always learn from the way they are scripted. From your post, I only see envy, jealousy.

It's dissapointing to see that coming from someone like you Chojrak.

"Do not overrate what you have received, nor envy others. He who envies others does not obtain peace of mind."
-Buddha
 
My english is not good enough to explain what i ment but i'll try. He think's he's 0pr0 master master while posting understandable codes for many peoples. But in my opinion he's regular lua scripter.
 
this function its only an example to you know how use LUAgd
i will post an example to use socket too ^^
My english is not good enough to explain what i ment but i'll try. He think's he's 0pr0 master master while posting understandable codes for many peoples. But in my opinion he's regular lua scripter.
i respect your opinion about me :p
i am really regular lua scripter ^^ i am not OMG PROX³²¹³ OMG!
I know people like this and this its not my case ^^
and this iscript its not understandable
._.
Lua:
 function drawnArea(area,name,pixels)
        --- If your server dont have lua GD it open
        if not gd then
             require('gd')
        end
        --- If pixels = nil set pixels to 1
        pixels = pixels or 1
        --- Create photo (in var) and set size (x and y)
        im = gd.createTrueColor(#area[1]*pixels,#area*pixels)
        --- allocate colors, first white, second red etc (look it at luaGD reference)
        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),
        }
        --- Many loops...
        for Y=1,#area do
           for X=1,#area[Y] do
                         --- Here set size of each pixel
                        for px=1,pixels do
                                for py=1,pixels do
                                        --- Here insert pixel
                                        im:setPixel((((X*pixels)+px)-pixels-1), (((Y*pixels)+py)-pixels-1),colors[area[(Y)][(X)]])
                                end
                        end
                end
        end
        --- if format of image its not .png it sets to png
        if name:sub(name:len()-3,-1) ~= '.png' then
                name = name..'.png'
        end
        --- create photo, and return true if sucess.
        return im:png(name)
end
easy ._.
 
@Mock:
It's really not understandable for many peoples.
And sure, post more examples. I just was angry and writing all what was on my mind.
 
Why the fuck are you posting these useless functions? I know kids are masturbing on your scripts but why? Omg it's fucking useless.

Dude its not useless, you can learn from them or branch this off into something more useful...Thanks Mock!!! I love your scripts they teach me a lot of cool stuff.
 
stop bump ancient threads, o btw this is good function
 
Back
Top