ID:2642180
 
Not a bug
BYOND Version:513
Operating System:Windows 10 Home 64-bit
Web Browser:Chrome 87.0.4280.88
Applies to:DM Language
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
I have been trying to turn a object around while it was 4 or more overlays . Whenever turned the overlays are not being properly turned , and are instead more to the NORTH/SOUTH of the sprite , when they are supposed to be in the exact middle.
Numbered Steps to Reproduce Problem:
1.Create a object with multiple overlays that have an offset
2.Create a matrix and turn the object
Code Snippet (if applicable) to Reproduce Problem:
The code turning the obj
/// Visually shows that the floodlight has been tipped and breaks all the lights in it.
/obj/machinery/floodlightcombat/proc/tip_over()
for(var/obj/item/light_bulb/tube/T in contents)
T.status = 2
update_icon()
density = FALSE
tipped = 1
transform = turn( NORTH, 90)


The code handling overlays
/obj/machinery/floodlightcombat/update_overlays()
. = ..()
var/offsetX
var/offsetY
/// Used to define which slot is targeted on the sprite and then adjust the overlay.
var/target_slot = 1
for(var/obj/item/light_bulb/tube/target in contents)
switch(target_slot)
if(1)
offsetX = 0
offsetY = 0
if(2)
offsetX = 6
offsetY = 0
if(3)
offsetX = 0
offsetY = 5
if(4)
offsetX = 6
offsetY = 5
. += image('icons/obj/machines/floodlight.dmi', src, "floodlightcombat_[target.status ? "brokenlight" : "workinglight"]", ABOVE_OBJ_LAYER, NORTH, offsetX, offsetY)
target_slot++

Expected Results:
All the overlays being properly turned
Actual Results:
All overlays shift upwards.
Does the problem occur:
Every time? Or how often?
Everytime i tried.
In other games?
Unknown , but it has happened in SS13 TGMC codebase.

When does the problem NOT occur?
Always occurs.

A photo of the issue if it helps.
https://imgur.com/a/MtXfVTn


You're setting transform incorrectly. turn(NORTH,90) returns WEST, which is 8, which is not a matrix.

The pixel offsets you're using for the floodlight also will not turn with the icon. The correct way to handle this would be to give the floodlight image a transform that adds those as a translation matrix instead of setting pixel_x/y offsets. Or, you could apply KEEP_TOGETHER to the parent. Which version is preferable depends on your use case.
Lummox JR resolved issue (Not a bug)
Thanks for the answer , sorry for the false report . The object already had the KEEP_TOGHETER appearance flag assigned to it, but since overlays are by default assigned the KEEP_APART it did nothing.
In response to SPCR
Just to clarify, overlays don't use KEEP_APART by default, unless you meant in your specific project. So under vanilla conditions, KEEP_TOGETHER would have solved it. However if you use KEEP_APART on the overlay, or give it a different plane from its parent object which forces KEEP_APART behavior, then the grouping can't happen.