ID:265142
 
Does anyone know a way that I can compact this


obj/buy
icon='buymenu.dmi'
name=""
bl
icon_state="bl"
New(client/C)
screen_loc="1,1"
C.screen+=src
ul
icon_state="ul"
New(client/C)
screen_loc="1,5"
C.screen+=src
ur
icon_state="ur"
New(client/C)
screen_loc="4,5"
C.screen+=src
br
icon_state="br"
New(client/C)
screen_loc="4,1"
C.screen+=src
l
icon_state="l"
New(client/C)
screen_loc="1,4"
C.screen+=src
r
icon_state="r"
New(client/C)
screen_loc="4,4"
C.screen+=src
l2
icon_state="l"
New(client/C)
screen_loc="1,3"
C.screen+=src
r2
icon_state="r"
New(client/C)
screen_loc="4,3"
C.screen+=src
l3
icon_state="l"
New(client/C)
screen_loc="1,2"
C.screen+=src
r3
icon_state="r"
New(client/C)
screen_loc="4,2"
C.screen+=src
b
icon_state="b"
New(client/C)
screen_loc="2,1"
C.screen+=src
u
icon_state="u"
New(client/C)
screen_loc="2,5"
C.screen+=src
b2
icon_state="b"
New(client/C)
screen_loc="3,1"
C.screen+=src
u2
icon_state="u"
New(client/C)
screen_loc="3,5"
C.screen+=src
mob/verb/Test()
new/obj/buy/bl(src.client)
new/obj/buy/ul(src.client)
new/obj/buy/br(src.client)
new/obj/buy/ur(src.client)
new/obj/buy/r(src.client)
new/obj/buy/l(src.client)
new/obj/buy/r2(src.client)
new/obj/buy/l2(src.client)
new/obj/buy/r3(src.client)
new/obj/buy/l3(src.client)
new/obj/buy/b(src.client)
new/obj/buy/u(src.client)
new/obj/buy/b2(src.client)
new/obj/buy/u2(src.client)
mob/verb/Test2()
for(var/obj/buy/A in client.screen)
del(A)
Well, the first thing that comes to mind is in your new code. You could use the typesof() proc to compact and automate the process a little more:

var/list/types = typesof(/obj/buy) - /obj/buy //You don't want base type included
for(var/newtype in types)
new newtype(client)

One way you could cut down on the New procs is by using the parent New proc. This is mainly because each New proc that you use does the same thing:

obj/buy
New(var/client/C)
..()
C.screen += src
bl
screen_loc = "1,1"
ul
screen_loc = "1,5"
//continue with rest
In response to English
Thanks :)