ID:2129786
 
(See the best response by FKI.)


Problem description: Can anyone explain exactly how float layers work?

Best response
thats good insight thank you! somes a touch confusing but i believe i understand it thanks
In response to William1of89
To offer some contrast, let's say I did this:

obj
item_appearance
// By default, all /obj/item_appearance objects will
// appear one layer above the default MOB_LAYER (which is 4)
layer = MOB_LAYER + 1

shirt
icon = 'a_shirt.dmi'

mob
verb/change_layer(l as num)
layer = l

verb/dress_up()
overlays += /obj/item_appearance/shirt

verb/dress_down()
overlays -= /obj/item_appearance/shirt


In this example, the shirt object would appear above you by default. But if you were to use the change_layer() verb and input a number greater than MOB_LAYER (which is 4, remember?), then the shirt would appear below you. Your layer changes but the shirt remains appearing above the MOB_LAYER. FLOAT_LAYER remedies this.

Take this instead:

obj
item_appearance
// By default, all /obj/item_appearance objects will
// "snap" to the player's layer.
layer = FLOAT_LAYER

shirt
icon = 'a_shirt.dmi'
layer = FLOAT_LAYER + 1


With this, the shirt would always appear above you, as it should.
In response to FKI
"Float layers" is a behavior unique to all negative layers. FLOAT_LAYER is a constant defined as -1. Adding 1 to FLOAT_LAYER will result in a non-floating layer.

Lower float layers are still drawn below higher float layers, i.e. -1 is above -2, which is above -5, etc.