ID:977334
 
Code:
        for(var/y = 0 to 4)
for(var/x = 0 to 5)
var/px = x * 40 + 10
var/py = y * 40 + 1400

var/HudObject/h = add(px, py, "test")
h.name = "open_slot"
open_slots += h


Problem description:
If I change the y value about 4 the layout on the screen somehow breaks. Here are the before and after.

How it should be : http://i.imgur.com/4DrDs.png
How it is when I increase y beyond 4 : http://i.imgur.com/0vATc.png

Any ideas?
Assuming that you're just setting the HudObject's pixel_x/y (or its screen_loc's pixel_x/y), the problem is that pixel offests are only reliable within a range of one tile size (±32 usually). You need to actually shift the tile coordinate for any pixel offset greater than the tile size.

So right now you're calculating what I'd call the "absolute pixel x/y". You need to break that into tiles (by dividing by icon_size and flooring with round(x)) and pixel offests (by modding it with icon_size).