ID:162810
 
Oaky I get 8 errors saying:
1bitconverter.dm:14:error:GetPixel:undefined proc
1bitconverter.dm:15:error:r:undefined var
1bitconverter.dm:15:error:g:undefined var
1bitconverter.dm:15:error:b:undefined var
1bitconverter.dm:16:error:rgb:undefined var
1bitconverter.dm:16:error:SwapColor:undefined proc
1bitconverter.dm:18:error:rgb:undefined var
1bitconverter.dm:18:error:SwapColor:undefined proc
1bitconverter.dm:3::warning: operation has no effect here

What im trying to do, is if the pixel is darker than half, then it turns black, else it turns white. And to call the for every pixel in your icon. What the effect is, im trying to get a 1-bit icon convereter to turn a regular icon, into well a 1-bit icon. I ddi it by hand by checking the colors hues here:


And heres the code:
mob/verb/Convert()
src.icon='1-bit.dmi'
src.Converter()
mob/var
X=1
Y=1
numba=1
mob/proc/Converter()
src.icon='1-bit.dmi'
X=1
Y=1
numba=1
Loop
GetPixel(X,Y,null,dir=0,frame=1,moving=0)
if(30*r+59*g+11*b > 7650)
SwapColor(rgb,0,0,0)
else
SwapColor(rgb,255,255,255)
if(numba>=32)
Y+=1
numba=1
goto Loop
numba+=1
X=numba
goto Loop
You're using GetPixel() wrong.

Except I wouldn't really know, because no one knows how to use it anyways. And you can replace "Loop" with a while() loop. goto Labels in here are unnecessary.

You could always just change the icon/icon_state instead of doing all this complicated stuff.
In response to Kaiochao2536
Well im litterily making new icons with it. Im trying to change the icons into 1-bit format, which would be very useful for some game designers, or if some people wanna cheat in a pixel art contest, and more.
In response to Bakasensei
Okay I got it working now(I hope), but when I convert the icon, checking every color crashes the game. So I was wondering if there was any simpler way to do this?
mob/var
px
px2
py
py2
mob/verb/Converter()
var/icon/cp=icon('1-bit.dmi')
for(var/px = 0 to 64) for(var/py = 0 to 64)
for(var/px2 = 65 to 255) for(var/py2 = 65 to 255)
cp.SwapColor(rgb(px,px,px),rgb(py,py,py))
cp.SwapColor(rgb(px2,px2,px2),rgb(py2,py2,py2))
src.icon=cp