ID:147230
 
I am working on a game that reads the basic BYOND map and ouputs it to a user as text. A problem has occured though in the process of it displaying what I'm telling it to, where as it does do its job of reading the map and displaying it all in text to the user, but it also distorts the output by displaying the turf included under the user.

mob/proc/ShowMap(R=11)
var/TopLeftX = x - R
var/TopLeftY = y + R /2
var/LowRightX = x + R
var/LowRightY = y - R /2
var/buf = ""
for(var/Ye = TopLeftY, Ye >= LowRightY, Ye--)
for(var/Ex = TopLeftX, Ex <= LowRightX, Ex++)
var/turf/T = locate(Ex,Ye,z)
var/mob/M = locate() in T
if(M)
buf += "[usr.symbol]"
if(T)
buf += T.symbol
buf += "\n"
src << mb_msgout(buf)


The only problem I'm having with this is that I can't figure out how to get it to not include that one turf, I'v tried various ways of subtracting the turf in the users coordinates but all have failed. Any help is much appreciated.

mb_msgout() Is just a part of Ebonshadow's library for displaying colors in telnet and BYOND clients. The symbol variable is obviously that turf/mob's designated symbol to display.

Here is an example of the problem in displaying.

^~~~~~~~~~~############
~~~~~~~~~~~############
#########^~############
#########^~############
#########^~############
^^^^^^^^^^~@############ <--- right here is the line that
~~~~~~~~~~~~~~~~~~~~~~~ shows the mobile, and also
#########~######^^^^^^^ where the output displaces in
^^^^#####~######^^^^^^^ showing the turf that would be
~~~^#####~######^^^^^^^ under the mobile.(the @ symbol ##~######~######^^^^^^^ is the current user.)
##~######~######^^^^^^^
Kusanagi wrote:
var/turf/T = locate(Ex,Ye,z)
var/mob/M = locate() in T
if(M)
buf += "[usr.symbol]"
if(T)
buf += T.symbol

If what i gathered is right, the if statements are causing the problem. What you have now is, if there is a mob in the current turf, display the mob symbol, and also print out the turf symbol aswell.

What you want to do is to change that 'if(T)' to an else, hence making it, if there is a mob in the current turf, display the mob symbol, else, print out the turf symbol.
eg
if(M) // if a mob was found
buf += "[usr.symbol]" // add its symbol to the buffer
else
buf += T.symbol // add the turf symbol to the buffer
In response to Lazyboy
You'd still want to make sure T existed.
else if(T)


In response to Airjoe
Thanks guys, problem solved.
In response to Airjoe
You don't need to check if T is still there because there is no such thing as a location without a turf.

~~> Dragon Lord
In response to Unknown Person
No, Airjoe was absolutely correct. What Lazy had posted without the check caused errors since it was not checking for the T.