ID:2015376
 
Code:
var
tooltip_vars = list("hands" = "noname", "attack" = "Attack ", "mag_attack" = "Magic Attack",
"on_hit" = "noname","on_hit_desc"= "noname","desc" = "noname", "value" = "Value", "type" = "noname")
tt_start_format = list("<span style='font-family:Arial;font-size:9pt;color:#66ffff;'>","<font color = white>",
"<font color = white>", "<font color = lime>",
"<span style='font-family:Arial; color:lime; font-size:8pt;'>",
"<span style='font-family:Arial; color:yellow; font-style:italic; font-size:7pt;'>",
"<span style='font-family:Arial; color:yellow; font-size:7pt;'>","")
tt_end_format = list("</span>","</font>","</font>","</font>","</span>","</span>","</span>","")

proc
Show_Tooltip(var/Interface/Inv_Slot/n)
if(!n || !n.occupied_by)
return

var/Item/o = n.occupied_by
var/r_color = "white"
switch(o.rarity)
if("Common")
r_color = "white"
if("Uncommon")
r_color = "green"
if("Rare")
r_color = "#3399ff"
if("Mythical")
r_color = "violet"
if("Legendary")
r_color = "orange"

src.maptext += "<font color = [r_color] size = 3><b>[o.name]</b></font> \n"
var/lines = 1
var/hbuff = 32

if(length(o.name) >= 16)
lines += 1
hbuff = 32

if(length(o.name) == 16)
hbuff = 16

for(var/i = 1; i <= o.tooltip_vars.len; i++)
if(k_get_occurrence(o.vars[o.tooltip_vars[i]], "\n", 1))
lines += 1

if(length("[o.vars[o.tooltip_vars[i]]]") > 0)
lines += 1
//if(length(o.vars[o.tooltip_vars[i]]) >= 24)
//_message(world, "long [text2num(length(o.vars[o.tooltip_vars[i]]))/24]. adding [round(text2num(length(o.vars[o.tooltip_vars[i]]))/24)] lines")
//lines += round(text2num(length(o.vars[o.tooltip_vars[i]]))/24)

if(o.tooltip_vars[o.tooltip_vars[i]] != "noname" && length("[o.vars[o.tooltip_vars[i]]]") > 0)
src.maptext += "[o.tt_start_format[i]][o.tooltip_vars[o.tooltip_vars[i]]] [o.vars[o.tooltip_vars[i]]][o.tt_end_format[i]] \n"
//world.log << "[o.tt_start_format[i]][o.tooltip_vars[o.tooltip_vars[i]]] [o.vars[o.tooltip_vars[i]]][o.tt_end_format[i]] \n"
else
src.maptext += "[o.tt_start_format[i]][o.vars[o.tooltip_vars[i]]][o.tt_end_format[i]] \n"
//world.log << "[o.tt_start_format[i]][o.vars[o.tooltip_vars[i]]][o.tt_end_format[i]] \n"


world.log << src.maptext
var/w = 160
var/h = (lines * 16) + hbuff


var/icon/i = new(src.icon)
i.Scale(w, h)
src.icon = i

src.maptext_width = 152
src.maptext_height = h
src.maptext_y = 12
src.maptext_x = 4

var/pos = k_get_occurrence(n.screen_loc, ",", 1)
var/xpos = k_get_occurrence(n.screen_loc, ":", 1)
var/ypos = k_get_occurrence(n.screen_loc, ":", 2)
var/sx = ""
var/sy = ""


if(xpos)
sx = text2num(copytext(n.screen_loc, 1, xpos)) + 1
else
sx = text2num(copytext(n.screen_loc, 1, pos)) + 1

if(ypos)
sy = text2num(copytext(n.screen_loc, pos+1, ypos)) - 7
else
sy = text2num(copytext(n.screen_loc, pos)) - 7

src.screen_loc = "[sx], [sy]"
usr.client.screen += src


Problem description:
I'm working on setting up some tooltips and I'm having an odd issue with maptext displaying the last value in a list it loops through.

The proc is designed to look at 3 lists to get the variables to display and how they should each be formatted in the maptext. The idea was to save having to duplicate the tooltip code to each obj type that can have a tooltip.

The problem is that the final value in the list is not properly displaying. If the text is shorter than the maptext width, it does not display at all. if it's longer than the width, it only partially displays. None of the other values have this problem.

Outputting the maptext shows that it's generating correctly. I've tried adjusting the maptext height and shifting the offset around, but none of that is working. I'm not sure what the cause is. It's always the last value though. I can continuously add values to the lists and it'll display all but the last.

Example shots:

http://imgur.com/YhGYJXB
http://imgur.com/Mytudyt

maptext output:
<font color = white size = 3><b>Short Sword</b></font> 
<span style='font-family:Arial;font-size:9pt;color:#66ffff;'>One Handed</span>
<font color = white>Attack 0</font>
<font color = white>Magic Attack 0</font>
<font color = lime>Firestorm</font>
<span style='font-family:Arial; color:lime; font-size:8pt;'>Burns the target for 5 fire damage</span>
<span style='font-family:Arial; color:yellow; font-style:italic; font-size:7pt;'>
short norm</span>
<span style='font-family:Arial; color:yellow; font-size:7pt;'>Value 0</span>
/Weapon/Short_Sword

<font color = #3399ff size = 3><b>Rare Short Sword</b></font>
<span style='font-family:Arial;font-size:9pt;color:#66ffff;'>One Handed</span>
<font color = white>Attack 0</font>
<font color = white>Magic Attack 0</font>
<font color = lime>Firestorm</font>
<span style='font-family:Arial; color:lime; font-size:8pt;'>Burns the target for 5 fire damage</span>
<span style='font-family:Arial; color:yellow; font-style:italic; font-size:7pt;'>
short norm tes tes tes tes test testt test stes test test test</span>
<span style='font-family:Arial; color:yellow; font-size:7pt;'>Value 0</span>
/Weapon/Rare_Short_Sword

I figured it out. It was caused by the newline at the end of the last value. I've added a check to see if it's the last value being shown to stop doing new lines.
Are you still working on TES?