ID:259192
 
Sometimes I want to overlay not just an icon, but a particular state of that icon. Here's the code I used:

proc
hScreen_OverlayArrows(myDir)
if(hScreen_hasArrows && \
istype(get_step(src, myDir), /turf/hScreen_screenBorder))
switch(myDir)
if(EAST)
overlays += /obj/hScreen_arrowOverlay/east
if(WEST)
overlays += /obj/hScreen_arrowOverlay/west
if(NORTH)
overlays += /obj/hScreen_arrowOverlay/north
if(SOUTH)
overlays += /obj/hScreen_arrowOverlay/south


// This is a "helper" class for easy overlay creation.
hScreen_arrowOverlay
icon = 'entrancePad.dmi'

east
icon_state = "east"
west
icon_state = "west"
north
icon_state = "north"
south
icon_state = "south"

My question is, is there an easy way to create overlays with a certain state, without resorting to extra classes (as here) or creating "dummy" objects?
On 7/23/00 3:42 pm Guy T. wrote:

My question is, is there an easy way to create overlays with a certain state, without resorting to extra classes (as here) or creating "dummy" objects?

Off the top of my head, I can't think of a really clean notation, but you could do something like this:

proc/addoverlay(myobj,myicon,mystate)
var/obj/O = new mytype()
O.icon = myicon
O.icon_state = mystate
myobj:overlays += O
del O

It would be nice if DM supported this intrinsically, but it's kind of a notational problem passing multiple arguments to the overlay list. I suppose we could have some sort of icon() function or perhaps use associative arrays, but both seem hacky.

In response to Tom H.
It would be nice if DM supported this intrinsically, but it's kind of a notational problem passing multiple arguments to the overlay list. I suppose we could have some sort of icon() function or perhaps use associative arrays, but both seem hacky.

Yep, no need to add more complexity. Your example should be more than sufficient. Thanks!