ID:1724894
 
Keywords: image, new, override
(See the best response by Mightymo.)
Code:
image
New(a)
src.alpha=a
..()

image/One=image('icon.dmi',locate(1,1,1),"state",20)


Problem description:

I want to assign some image objects an alpha value upon creation what am I doing wrong
Best response
You have to explicitly call new.

image
New()
src.alpha=100
..()

mob/verb
test()
var/image/One=new/image('icon.dmi',locate(1,1,1),"state",20)
usr << One
Sorry I made a mistake I meant src.alpha=a
So when I call new I can pass the alpha there

But I fear that this way I am ruining the default new/image parameters. I just want to add a var for alpha upon creation.So I can pass alpha value from the new proc
In response to Victorqr
Just allow for all of the arguments. If you don't want to ruin the default image, consider deriving a type.

image
alpha
New(a,b,c,d)
src.alpha=d
..()

mob/verb
test()
var/image/One=new/image/alpha('icon.dmi',locate(1,1,1),"state",100)
usr << One
Unless this was changed recently, /image/New() and /proc/image() cannot be sanely overridden.

Though before we even get to that, it seems extremely strange to need to set a default alpha value upon creation for all /image's.
You probably want to do something like this instead:

image/One=image('icon.dmi',locate(1,1,1),"state",20)
One.alpha = a
Yeah I want to do this but for the sake of sparing some code it would be much better overriding the obj constructor, the New() proc