ID:823558

(See the best response by DarkCampainger.)
Code:
 ```mob/proc/ShowMap() var/tmp/buf = "" for(var/xx = x-client.view, xx < x+client.view+1, xx++) for(var/yy = y-client.view, yy < y+client.view+16, yy++) var/turf/T = locate(xx,yy,z) var/mob/M = locate() in T if(M) buf += M.text else buf += T.text buf += "\n" src << buf ```

Problem description:

North is to the right south is to the left. when moving how to fix it?

same with east and west... west is up and east is down lol wtf T.T
ok i fixed it sorta but now the map is upside down when printed like south is north and north is south lol

 ```mob/proc/ShowMap() var/tmp/buf = "" for(var/yy = y-client.view, yy < y+client.view+1, yy++) for(var/xx = x-client.view, xx < x+client.view+16, xx++) var/turf/T = locate(xx,yy,z) var/mob/M = locate() in T if(M) buf += M.text else buf += T.text buf += "\n" src << buf ```
Best response
You have your nested loops reversed. You're starting in the bottom-left corner, but your iterating over the rows, then moving over a column. Because you're building your buffer left-to-right/top-to-bottom, you've flipped your map.

You want:
 ```mob/proc/ShowMap() var buf = "" top = min(y+client.view, world.maxy) bottom = max(y-client.view, 1) left = max(x-client.view, 1) right = min(x+client.view, world.maxx) for(var/yy = top, yy >= bottom, yy--) for(var/xx = left, xx <= right, xx++) var/turf/T = locate(xx,yy,z) var/mob/M = locate() in T if(M) buf += M.text else buf += T.text buf += "\n" src << buf ```

So now it loops through the columns, then moves down a row. You notice I also reversed the order of the yy loop.

I also added some bounds checking so your view doesn't go off the map. Also, the 'tmp' modifier for variables is just for excluding it from savefiles.
 #3 Jun 19 2012, 1:32 pm thanks!
 #4 Jul 27 2012, 4:39 pm Hey i was wondering DarkCampainger is there anyway to wrap the map using this? I'm not sure how to :/