proc/card_link(var/c_name = "")
if(!c_name) return ""
if(!findtext(c_name,{"~"})) return c_name
usr << "DEBUG1 - [c_name]"
var/workdesc = c_name
var/newdesc = ""
while(findtext(workdesc,{"~"}))
var/chop_txt = ""
var/q_pos = findtext(workdesc,{"~"})
if(q_pos != 1)
newdesc += copytext(workdesc,1,q_pos)
workdesc = copytext(workdesc,q_pos,length(workdesc)+1)
else
workdesc = copytext(workdesc,2,length(workdesc)+1)
if(findtext(workdesc,"~"))
var/q_pos2 = findtext(workdesc,{"~"})
chop_txt = copytext(workdesc,1,q_pos2)
workdesc = copytext(workdesc,q_pos2+1,length(workdesc)+1)
usr << "DEBUG2 - =[chop_txt]="
usr << "DEBUG3 - =[lowertext(chop_txt)]="
var/obj/cards/Z
for(var/obj/cards/C in cards) if(lowertext(C.name) == lowertext(chop_txt))
usr << "DEBUG4 - [C.type] found!"
Z = new C.type
break
if(Z) chop_txt = {"<a title='[c_name]' href='?src=\ref[usr];cshow=[Z.type]'><IMG SRC=\ref[Z.icon] ICONSTATE="[Z.icon_state]" ICONDIR=NORTH></a>"}
else chop_txt = {"~[chop_txt]~"}
usr << "DEBUG5 - [chop_txt]"
newdesc += chop_txt
else
newdesc += "~[workdesc]"
workdesc = ""
if(!findtext(workdesc,{"~"}))
newdesc += workdesc
return newdesc
obj/cards/monster/PHRA
icon = 'PHRA.dmi'
EN002
name = "The Phantom Knights of Stained Greaves"
attrib = "DARK"
desc = {"If a "The Phantom Knights" monster(s) is Special Summoned to your field: You can Special Summon this card from your hand, then you can increase its Level by 1. You can banish this card from your GY; Special Summon 1 "The Phantom Knights" monster from your hand, except "The Phantom Knights of Stained Greaves", then you can increase its Level by 1. You can only use each effect of "The Phantom Knights of Stained Greaves" once per turn."}
stype = "Warrior"
icon_state = "02"
level = 3
atk = 1200
def = 600
effect = 1
EN040
name = "Raiders' Knight"
attrib = "DARK"
desc = {"2 Level 4 DARK monsters<br>(This card is always treated as a "The Phantom Knights" and "Raidraptor" card.)<br>You can detach 1 material from this card; Special Summon from your Extra Deck, 1 "The Phantom Knights", "Raidraptor", or "Xyz Dragon" monster that is 1 Rank higher or lower than this card, by using this face-up card you control as material, but destroy it during your opponent's next End Phase. (This is treated as an Xyz Summon. Transfer its materials to the Summoned monster.) You can only use this effect of "Raiders' Knight" once per turn."}
stype = "Warrior"
icon_state = "40"
rank = 4
atk = 2000
def = 0
effect = 1
xyz = 1
Problem description:
So the code above I posted is a bit of code I added to my game for converting a specific string in to a hyperlink image. If you've ever played something like World of Warcraft, its similar to the item link. If you, in chat type out "blahblah ~CARD NAME HERE~" blahblah, and it finds a card with a matching name, it'll replace that string with a picture of the card that you can click on to view its full details.
The problem is the code seems to be breaking for obj with an apostrophe in their name. In the above 2nd section of code. "The Phantom Knights of Stained Greaves" would work just fine and link the image without issue. But "Raiders' Knight" doesn't work. I'm not sure what I'm overlooking here though because the debug lines I'm using seem to indicate its not breaking.
If I run Greaves through the proc as "~The Phantom Knights of Stained Greaves~", the output results are...
DEBUG1 - ~The Phantom Knights of Stained Greaves~
DEBUG2 - =The Phantom Knights of Stained Greaves=
DEBUG3 - =the phantom knights of stained greaves=
DEBUG4 - /obj/cards/monster/PHRA/EN002 found!
DEBUG5 - INSERT HYPERLINK IMAGE HERE
But if I run Raiders' Knight through the proc as "~Raiders' Knight~", I get the following outputs...
DEBUG1 - ~Raiders' Knight~
DEBUG2 - =Raiders' Knight=
DEBUG3 - =raiders' knight=
DEBUG5 - ~Raiders' Knight~
its discovering and converting the text to lowercase like it should, but it doesn't seem to be matching it to the name of the obj.
for(var/obj/cards/C in cards) if(lowertext(C.name) == lowertext(chop_txt))
usr << "DEBUG4 - [C.type] found!"
Z = new C.type
break
For clarification, the "cards" list in the above code is a list of the card obj in the game that players generally have access to.
This appears to be the section of the code where it's acting up but I cant figure out why. An obj with a quotation mark in the name gives the same result some I'm assuming something's breaking somewhere here due to the string not being properly enclosed but I'm not sure why. Other special characters like Hyphens work just fine.
Also, cmptext() is a built-in case-insensitive text comparison.