mob/verb/testTextureProc()
var/Merger/Chalk/b1 = new()
var/Merger/Cobble/t1 = new()
AddTexture(b1, t1)
Merger/Chalk
name = "Chalk"
icon = 'Bases/Chalk.dmi'
icon_state = "Chalk"
subtype = "Base"
Merger/Cobble
name = "Cobble"
icon = 'Textures/Cobble.dmi'
icon_state = "Cobble"
subtype = "Texture"
proc/AddTexture(var/Merger/base, var/Merger/texture, saveas="Test.png")
var/icon/savem = base.icon //icon(base.icon, base.icon_state)
var/icon/textr = texture.icon //icon(texture.icon, texture.icon_state)
var/icon/ibase = base.icon //icon(base.icon, base.icon_state)
world << savem
world << textr
world << ibase
for(var/x = 1, x <= 16, x++)
for(var/y = 1, y <= 16, y++)
var/rgb0 = AvgRGB(texture.icon, texture.icon_state)
var/rgb1 = textr.GetPixel(x,y)
var/rgb2 = ibase.GetPixel(x,y)
var/r0=base2dec(copytext(rgb0,2,4),16)
var/b0=base2dec(copytext(rgb0,4,6),16)
var/g0=base2dec(copytext(rgb0,6,8),16)
var/r1=base2dec(copytext(rgb1,2,4),16)
var/b1=base2dec(copytext(rgb1,4,6),16)
var/g1=base2dec(copytext(rgb1,6,8),16)
var/r2=base2dec(copytext(rgb2,2,4),16)
var/b2=base2dec(copytext(rgb2,4,6),16)
var/g2=base2dec(copytext(rgb2,6,8),16)
var/rcng = r2 + (r1 - r0)
var/bcng = b2 + (b1 - b0)
var/gcng = g2 + (g1 - g0)
savem.DrawBox(rgb(rcng,bcng,gcng), x, y)
fcopy(savem, "Output/[saveas].png")
Problem description:
runtime error: Cannot execute null.GetPixel().
proc name: AddTexture (/proc/AddTexture)
source file: Run.dm,28
usr: Guest-2634703988 (/mob)
src: null
call stack:
AddTexture(Chalk (/Merger/Chalk), Cobble (/Merger/Cobble), "Test.png")
Guest-2634703988 (/mob): testTextureProc()
I can't understand why I keep getting null error. It seems to be set fine, and even outputs as the icon it's suppose to, but seems to lose it's icon before it attempts getpixel.
Edit:
Merger //Base for icons
parent_type = /obj/
var/list/mergewith = null
var/subtype = ""
(Merger is equal to object.)