ID:146684
 
I'd like to thank Gazoot and YMIhere for helping me with the current version of my look command. You guys have helped me out alot! Thanks!

Quick Note: Look (T.text/M.text) does not seem to be compatible with my colors procedure or vice versa.

Code:
///////////////////////////////////////////////////////////
// My Pcolor Code Snippit (using Deadron's Text Handling)//
///////////////////////////////////////////////////////////

proc/colors(message as text)
message = strip_html(message)
message = dd_replaceText(message, "&R", "<font color = '#E10000'>")
message = dd_replaceText(message, "&r", "<font color = '#A30000'>")
message = dd_replaceText(message, "&B", "<font color = '#0022FF'>")
message = dd_replaceText(message, "&b", "<font color = '#001AC3'>")
message = dd_replaceText(message, "&G", "<font color = '#00E11E'>")
message = dd_replaceText(message, "&g", "<font color = '#009F00'>")
message = dd_replaceText(message, "&Y", "<font color = '#FCFF05'>")
message = dd_replaceText(message, "&y", "<font color = '#D7CC00'>")
message = dd_replaceText(message, "&C", "<font color = '#00FFFF'>")
message = dd_replaceText(message, "&c", "<font color = '#009694'>")
message = dd_replaceText(message, "&M", "<font color = '#FF00FF'>")
message = dd_replaceText(message, "&m", "<font color = '#AD2B9E'>")
message = dd_replaceText(message, "&D", "<font color = '#BFBFBF'>")
return message
////////////////////////////////////////////////////////////

////////////////////////////
// Simple Test Turf //
////////////////////////////

turf/earth/grass
icon = 'GRASS.dmi'
Type = "GRASS"
text = "&g."
Planet = "EARTH"

////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// The Current Look Command - It doesnt like the colors //
///////////////////////////////////////////////////////////

atom/var/Design
mob/
verb
look()
var/output = ""
var/range = 6
var/turf/start = locate(max(1, src.x-range/2), max(1, src.y-range/2), src.z)
var/turf/end = locate(min(world.maxx, src.x+range/2), min(world.maxy, src.y+range/2), src.z)

var/line = ""

for(var/turf/T in block(start, end))
if(!T.contents.len)
line += colors(T.text)
else
for(var/atom/movable/M in T)
line += colors(M.text)
break

if(lentext(line) == range+1)
output = line + "\n" + output
line = ""

world << "<pre>[output]</pre>"
///////////////////////////////////////////////////////////


Problem description:
- It seems to work fine if there is no color and on a white background, however my MUD is on a black background and uses colors.
- The code does not seem to like either multiple characters in text or the color procedure.
- I cant seem to actually get around it, I've used other variables in substitute but none seemed to have worked.
Sorry about the quick reply, but I gotta sleep in 5 mins. First, thanks for the credit. :) The biggest problem as I can see is that lentext will not be useful, since you are replacing the "&G" codes with html, which will make the string much longer than the range+1 that you test later on. So you need to use a counter for every added turf instead, and append the output when it is above range.

If it doesn't help, I'll explain more tomorrow.


/Gazoot