ID:264528
 
Code:
mob
proc
Scale(mob/M)
var/icon/I = new(M.icon)
I.Scale(64,64)
M.overlays = null
M.overlays += new/obj/A
M.overlays += new/obj/B
M.overlays += new/obj/C
M.overlays += new/obj/D
for(var/obj/A in M.overlays)
A.pixel_y = 32
A.layer = MOB_LAYER + 10
A.icon = I
A.icon_state = "0,1"
for(var/obj/B in M.overlays)
B.pixel_y = 32
B.pixel_x = 32
B.layer = MOB_LAYER + 10
B.icon = I
B.icon_state = "1,1"
for(var/obj/C in M.overlays)
C.pixel_x = 32
C.layer = MOB_LAYER + 10
C.icon = I
C.icon_state = "1,0"
for(var/obj/D in M.overlays)
D.layer = MOB_LAYER + 10
D.icon = I
D.icon_state = "0,0"
return
obj
A
B
C
D


Problem description:
Yeah... >_<<br/> Something I'm doing wrong.
I get no errors or warnings. DEBUG Mode or Not.
Yet... It fails in game.

Can anyone help me as to why this is and how can I fix it?
overlays is a special list, and does not contain objs. Looping through it looking for objs won't work. Instead, set the pixel_x/y and layer and etc. BEFORE you add the objs to overlays.

Also, if you have a mob/proc, there's no reason to pass an argument. Just use src.
In response to Garthor (#1)
Garthor wrote:
overlays is a special list, and does not contain objs. Looping through it looking for objs won't work. Instead, set the pixel_x/y and layer and etc. BEFORE you add the objs to overlays.

Also, if you have a mob/proc, there's no reason to pass an argument. Just use src.


Okay... So I am still completely lost.
My problem is I don't see the small things.
I read into your article about overlays being special as a list but I'm still a bit confused.
How can I take the selected mob (M) and Scale() to 64,64 and keep M's original icon values (icon states, delays, etc). Then proceed to making A, B, C, D the "1,0" "0,0" "0,1" "1,1" product from Scale() and make sure they have M's original values but in an enlarged icon form?
I really really do not wish to spend more time taking mob icons and enlarging them in Microsoft Paint/Photoshop/Gimp and then make the icon states (Icon x 4(Bottom Left, Bottom Right, Top Right, Top Left in Scale) = 4 x 20+ States = 80 x 50+ icons = ... No. I refuse.)

(In other words; "May I see an alteration/modification to my code snippet to achieve this?")
In response to Maximus_Alex2003 (#2)
Bump.
In response to Maximus_Alex2003 (#2)
The problem with the below goes on what Garthor said that overlays are special and so aren't a normal list.

mob
proc
Scale(mob/M)
var/icon/I = new(M.icon)
I.Scale(64,64)
M.overlays = null
M.overlays += new/obj/A
M.overlays += new/obj/B
M.overlays += new/obj/C
M.overlays += new/obj/D
for(var/obj/A in M.overlays)
A.pixel_y = 32
A.layer = MOB_LAYER + 10
A.icon = I
A.icon_state = "0,1"
for(var/obj/B in M.overlays)
B.pixel_y = 32
B.pixel_x = 32
B.layer = MOB_LAYER + 10
B.icon = I
B.icon_state = "1,1"
for(var/obj/C in M.overlays)
C.pixel_x = 32
C.layer = MOB_LAYER + 10
C.icon = I
C.icon_state = "1,0"
for(var/obj/D in M.overlays)
D.layer = MOB_LAYER + 10
D.icon = I
D.icon_state = "0,0"
return
obj
A
B
C
D


So what you need to do is create a new object which I've done in the below code and then "manipulate" the variables you want, after you've done that then you go about adding them as overlays and lastly nulling the players icon.

mob
proc
Scale(mob/M)
var/icon/I = new(M.icon)
I.Scale(64,64)
M.overlays = null

var/obj/A = new/obj/A //Creates the obj to be manipulated.
var/obj/B = new/obj/B
var/obj/C = new/obj/C
var/obj/D = new/obj/D

A.pixel_y = 32 //Sets your preferences.
A.layer = MOB_LAYER + 10
A.icon = I
A.icon_state = "0,1"

B.pixel_y = 32
B.pixel_x = 32
B.layer = MOB_LAYER + 10
B.icon = I
B.icon_state = "1,1"

C.pixel_x = 32
C.layer = MOB_LAYER + 10
C.icon = I
C.icon_state = "1,0"

D.layer = MOB_LAYER + 10
D.icon = I
D.icon_state = "0,0"

M.overlays+=A //Adds the manipulated objects as overlays.
M.overlays+=B
M.overlays+=C
M.overlays+=D
M.icon = null //Nulls the mobs icon so it doesn't show up under the overlays.


obj
A
B
C
D


TBH, you don't even need more then one obj, obj/A then you can just do something like this. Though just having a letter as the obj with no presets really won't make a dent in your resource size.

var/obj/A/A = new/obj/A
var/obj/A/B = new/obj/B
var/obj/A/C = new/obj/C
var/obj/A/D = new/obj/D
In response to THESINKING (#4)
THESINKING wrote:
The problem with the below goes on what Garthor said that overlays are special and so aren't a normal list.

Okay, (by the way, this is my alt key)
I've done it that way before.
But my main goal isn't acheived...
Is the built in proc Scale() unfinished or am I able to give the newly made overlays from the scale the same icon values (icon_states, delays, etc.) as the original unscaled icon?
In response to Random_Cookie (#5)
Random_Cookie wrote:
THESINKING wrote:
The problem with the below goes on what Garthor said that overlays are special and so aren't a normal list.

Okay, (by the way, this is my alt key)
I've done it that way before.
But my main goal isn't acheived...
Is the built in proc Scale() unfinished or am I able to give the newly made overlays from the scale the same icon values (icon_states, delays, etc.) as the original unscaled icon?

I was just posting yours so you could look at the difference. The bottom one is the one that works, I tested it myself and it scaled the icon to 64 x 64, I've never personally used Scale() myself except for this instance but I'm certain it will still keep those values.
In response to THESINKING (#6)
Nope. No dice.
I tried it your way by replacing
            var/obj/A = new/obj/A
var/obj/B = new/obj/B
var/obj/C = new/obj/C
var/obj/D = new/obj/D

with
            var/obj/A/A = new/obj/A
var/obj/A/B = new/obj/B
var/obj/A/C = new/obj/C
var/obj/A/D = new/obj/D

And all it does is copy M's current icon state.
It doesn't copy over all icon states or values.
Am I just being oblivious?
I'm sorry to bother you. It's just this thing has been bothering me for quite some time.
So I spent the last hour or so re-arranging and re-doing it all and still no dice.
In response to Random_Cookie (#7)
Random_Cookie wrote:
Nope. No dice.
I tried it your way by replacing
>             var/obj/A = new/obj/A
> var/obj/B = new/obj/B
> var/obj/C = new/obj/C
> var/obj/D = new/obj/D
>

with
>             var/obj/A/A = new/obj/A
> var/obj/A/B = new/obj/B
> var/obj/A/C = new/obj/C
> var/obj/A/D = new/obj/D
>

And all it does is copy M's current icon state.
It doesn't copy over all icon states or values.
Am I just being oblivious?
I'm sorry to bother you. It's just this thing has been bothering me for quite some time.
So I spent the last hour or so re-arranging and re-doing it all and still no dice.

If copying it that way isn't working just go with the one I posted originally, I was only posting that so you could see there was another way of doing it.

Here, this works, there's no need to edit anything unless you absolutely want to, btw, the spaces between the blocks of code are to make it easier for you to see what I'm doing to each obj.

mob
verb
Enlarge()
usr.Scale()

mob
proc
Scale(mob/M)
M = src
var/icon/I = new(M.icon)
I.Scale(64,64)
M.overlays = null

var/obj/A = new/obj/A //Creates the obj to be manipulated.
var/obj/B = new/obj/B
var/obj/C = new/obj/C
var/obj/D = new/obj/D

A.pixel_y = 32 //Sets your preferences.
A.layer = MOB_LAYER + 10
A.icon = I
A.icon_state = "0,1"

B.pixel_y = 32
B.pixel_x = 32
B.layer = MOB_LAYER + 10
B.icon = I
B.icon_state = "1,1"

C.pixel_x = 32
C.layer = MOB_LAYER + 10
C.icon = I
C.icon_state = "1,0"

D.layer = MOB_LAYER + 10
D.icon = I
D.icon_state = "0,0"

M.overlays+=A //Adds the manipulated objects as overlays.
M.overlays+=B
M.overlays+=C
M.overlays+=D
M.icon = null //Nulls the mobs icon so it doesn't show up under the overlays.


obj
A
B
C
D
In response to THESINKING (#8)
Arrgg...
Thank you for your help.
I'm sorry to be a bother but it's just not working.
Yes, it does Scale the source's icon.
No, it does not give the newly Scaled icons or whatever, the same values and icon states as the source's icon.

I'll just set it as a side project and fiddle with it time to time to get it right.

Thank you for your help.
If I could totally +Rep or +Kudos you, I would.
In response to Random_Cookie (#9)
Random_Cookie wrote:
Arrgg...
Thank you for your help.
I'm sorry to be a bother but it's just not working.
Yes, it does Scale the source's icon.
No, it does not give the newly Scaled icons or whatever, the same values and icon states as the source's icon.

I'll just set it as a side project and fiddle with it time to time to get it right.

Thank you for your help.
If I could totally +Rep or +Kudos you, I would.

Hmm... I think I get what you are asking now, I was totally spacing earlier. I think to have it change icon_states to be scaled also you'd have to call the scale proc for each specific one. Correct me if that's not what you are asking.
In response to THESINKING (#10)
Well, in a sense that's what I'm asking.
But... That wouldn't exactly copy the delays in the icon, if any.
Since the mob's icon I was trying to copy had a 'blinking' affect, the delay between eyes open and closed was down to nothing and in the original mob's icon, the delay was 6, 1, 1.
So yeah...
Anyways, thank you. Don't worry about this anymore.
Like I said, I'll just put it aside and focus on other things while I mingle with it once in a while.
In response to Random_Cookie (#9)
Random_Cookie wrote:
Arrgg...
Thank you for your help.
I'm sorry to be a bother but it's just not working.
Yes, it does Scale the source's icon.
No, it does not give the newly Scaled icons or whatever, the same values and icon states as the source's icon.

You would need to set the icon_states to be "[src.icon_state] 0,0" and etc. Unfortunately, there's no way to make those overlays permanently match your icon_state.
In response to Garthor (#12)
I think I know another problem he was talking about with delays. I was doing some more testing with it and I found that it changes all of those new icon_state delays to 1. It should hold the same properties as the original, not sure where to suggest that though so I figure whoever reads this can do it.
here's and easier way to code it.

mob/proc/Scale(var/xscale = 32, yscale = 32)
var/icon/I = new(src.icon)
I.Scale(xscale,yscale)
src.icon = null
src.overlays = new/list()// clear the overlays
for(var/x=0, x < round(xscale/32), x++)
for(var/y = 0, y < round(yscale/32), y++)
var/obj/A = new/obj
A.icon = I
A.pixel_x = round(32*x)
A.pixel_y = round(32*y)
A.layer = MOB_LAYER + 10
A.icon_state = "[x],[y]"
src.overlays += A
In response to Darker Emerald (#14)
Heh, here I am trying to do it the long and repetitive way and someone comes along and blows me away... xD
Wow. Thank you.
Very much appreciated.