ID:268595
 
I have s_smileys implented into my game and it works perfectly until you try to say 0.0.It freezes the game when you try to say it for some reason.I checked my coding it looks the same as all the others.All the others work fine but 0.0 freezes Dream Seeker and you have to close it using control+alt+delete.Any Ideas on how to fix this?I will post my smileys coding for that part incase its needed.

/////////////////////////////////////////////////////////////////////
// Spuzzum's Imbedded Smileys Library by Jeremy "Spuzzum" Gibson //
/////////////////////////////////////////////////////////////////////
/*
Just include this library and its accompanying icon, s_smileys.dmi
in your project. Then, whenever you send output to players, instead
of using

usr << "Blah blah blah! =)"

you can imbed the smileys using

usr << s_smileys( "Blah blah blah! =)" )


In other words, any text you make, rather than

usr << text

use

usr << s_smileys(text)


That's all there is to it! Have a nice day. ;-)


(Personally, I rather dislike having my text replaced with pictures.
But Tom wanted (rather, demanded ;-) this library, so I made it. =)


Contributors:
Deadron <ron@deadron.com> - for the dd_replacetext() proc
and supportive functions dd_text2list() and dd_list2text()

*/


/*****************************************************************************

The replacetext proc is a snippet of code I created from scratch some time ago
to be a method that doesn't involve lengthy parsing and then deparsing of a
text string. It is contained in replacetext.dm. If you get an error related
to 'duplicate proc definition', just exclude that file from this library by
removing its checkbox.

*****************************************************************************/


world/New()
..()
spawn()
var/L[0] //originally added typesof(/smiley) but the order was messed
for(var/S in typesof(/smiley)-/smiley)
L += S
var/A
for(A in L)
s_smileys += new A


var/s_smileys[0]

smiley
var
smileys[]
iconstate

//Allows s_smiley to work on HTML-encoded strings
New()
..()
for(var/smiley in smileys)
var/new_string = replacetext( replacetext(smiley, "<", "&lt;"), ">", "&gt;" )
if(!cmptext(new_string, smiley))
smileys += new_string

surprised_thoughtful_wink
smileys = list("<;|","<;-|","<;^|", "<;o|")
iconstate = "surprised/thoughtful wink"

sadistic
smileys = list(">=)",">:)",">:-)",">=-)",">=^)",">:^)",">=\]",">:\]",">:-\]",
">=-\]",">=^\]",">:^\]",">:>",">:->",">=->",">=^>",">:^>",">=o>",">:o>",
">=o)",">:o)",">=o\]",">:o\]")
iconstate = "sadistic"
surprised
smileys = list("<=)","<:)","<:-)","<=-)","<=^)","<:^)","<=\]","<:\]","<:-\]",
"<=-\]","<=^\]","<:^\]","<:>","<:->","<=->","<=^>","<:^>","<=o>","<:o>",
"<=o)","<:o)","<=o\]","<:o\]")
iconstate = "surprised"
angry
smileys = list(">=(",">:(",">:-(",">=-(",">=^(",">:^(",">=\[",">:\[",">:-\[",
">=-\[",">=^\[",">:^\[",">:<",">:-<",">=-<",">=^<",">:^<",">=o<",">:o<",
">=o(",">:o(",">_<",">.<",">o<")
iconstate = "angry"
sad_b
smileys = list("<=(","<:(","<:-(","<=-(","<=^(","<:^(","<=\[","<:\[","<:-\[",
"<=-\[","<=^\[","<:^\[","<:<","<:-<","<=-<","<=^<","<:^<","<:o\[","<:o(",
"<=o\[","<=o(")
iconstate = "sad_b"
mad_tongue
smileys = list(">=P",">:P",">:oP",">:-P",">=-P",">=^P",">:^P",">:oP",">=oP")
iconstate = "mad/tongue"
mad_tongue2
smileys = list(">=p",">:p",">:-p",">=-p",">=^p",">:^p",">=þ",">:þ",">:-þ",
">=-þ",">=^þ",">:^þ",">=op",">:op",">=oþ",">:oþ")
iconstate = "mad/tongue2"
sigh_tongue2
smileys = list("<=p","<:p","<:-p","<=-p","<=^p","<:^p","<=þ","<:þ","<:-þ",
"<=-þ","<=^þ","<:^þ","<=op","<:op","<=oþ","<:oþ")
iconstate = "sigh/tongue2"
sigh_tongue
smileys = list("<=P","<:P","<:-P","<=-P","<=^P","<:^P","<=oP","<:oP")
iconstate = "sigh/tongue"
evil_grin
smileys = list(">=D",">:D",">:-D",">=-D",">=^D",">:^D")
iconstate = "evil grin"
worried_grin
smileys = list("<=D","<:D","<:-D","<=-D","<=^D","<:^D")
iconstate = "worried grin"
naughty_wink
smileys = list(">;)",">;-)",">;^)",">;\]",">;-\]",">;^\]",">;>",">;->",">;^>",">;o>",
">;o)")
iconstate = "naughty wink"
surprised_wink
smileys = list("<;)","<;-)","<;^)","<;\]","<;-\]","<;^\]","<;>","<;->","<;^>","<;o>",
"<;o)")
iconstate = "surprised wink"
angry_wink
smileys = list(">;(",">;-(",">;^(",">;\[",">;-\[",">;^\[",">;<",">;-<",">;^<",">;o<",
">;o(")
iconstate = "angry wink"
sad_wink_b
smileys = list("<;(","<;-(","<;^(","<;\[","<;-\[","<;^\[","<;<","<;-<","<;^<",
"<;o<")
iconstate = "sad wink_b"
sad_wink_tongue2
smileys = list("<;p","<;-p","<;^p","<;þ","<;-þ","<;^þ","<;oþ","<;op")
iconstate = "sad wink/tongue2"
sad_wink_tongue
smileys = list("<;P","<;-P","<;^P","<;oP")
iconstate = "sad wink/tongue"
angry_thoughtful_wink
smileys = list(">;|",">;-|",">;^|",">;o|")
iconstate = "angry/thoughtful wink"
skeptical
smileys = list(">=|",">:|",">:-|",">=-|",">=^|",">:^|",,">=o|",">:o|")
iconstate = "skeptical"
confused
smileys = list("<=|","<:|","<:-|","<=-|","<=^|","<:^|","<=o|","<:o|")
iconstate = "confused"
angry_wink_tongue2
smileys = list(">;p",">;-p",">;^p",">;þ",">;-þ",">;^þ",">;oþ",">;op")
iconstate = "angry wink/tongue2"
angry_wink_tongue
smileys = list(">;P",">;-P",">;^P",">;oP")
iconstate = "angry wink/tongue"
angry_uncertain
smileys = list(">:/",">:\\",">=/",">=\\",">:o\\",">:o/",">=^/",">=^\\",">:^/",">:^\\",
">=-/",">=-\\",">:-/",">:-\\")
iconstate = "angry/uncertain"
frustrated
smileys = list(">=o",">:o",">:-o",">=-o",">=^o",">:^o",">=O",">:O",">:-O",
">=-O",">=^O",">:^O",">=oO",">:oO")
iconstate = "frustrated"
naughty_wink_grin
smileys = list(">;D",">;-D",">;^D",">;oD")
iconstate = "naughty wink/grin"
sheepish_wink_grin
smileys = list("<;D","<;-D","<;^D","<;oD")
iconstate = "sheepish wink/grin"
surprised_b
smileys = list("<=o","<:o","<:-o","<=-o","<=^o","<:^o","<=O","<:O","<:-O",
"<=-O","<=^O","<:^O","O.O","O_O","<=oO","<:oO")
iconstate = "surprised_b"
angry_weird
smileys = list(">:S",">=S",">=oS",">:oS",">:-S",">=-S",">:^S",">=^S",">:oS",">=oS",
">=}",">={",">:}",">:{",">:@",">:?",">=?",">:-?",">=-?",">:^?",">=^?",">:o?",">=o?")
iconstate = "angry/weird"
sad_weird
smileys = list("<:S","<=S","<=oS","<:oS","<:-S","<=-S","<:^S","<=^S","<:oS","<=oS",
"<=}","<={","<:}","<:{","<:@","<:?","<=?","<:-?","<=-?","<:^?","<=^?","<:o?","<=o?")
iconstate = "sad/weird"
sad_uncertain
smileys = list("<:/","<:\\","<=/","<=\\","<:o\\","<:o/","<=^/","<=^\\","<:^/","<:^\\",
"<=-/","<=-\\","<:-/","<:-\\")
iconstate = "sad/uncertain"
uncertain_skeptical2
smileys = list("/:/","/:\\","/=/","/=\\","/:o\\","/:o/","/=^/","/=^\\","/:^/","/:^\\",
"/=-/","/=-\\","/:-/","/:-\\","\\:/","\\:\\","\\=/","\\=\\","\\:o\\","\\:o/",
"\\=^/","\\=^\\","\\:^/","\\:^\\","\\=-/","\\=-\\","\\:-/","\\:-\\")
iconstate = "uncertain/skeptical2"
skeptical2
smileys = list("/=|","/:|","/:-|","/=-|","/=^|","/:^|","/=o|","/:o|","/=l",
"/:l","/:-l","/=-l","/=^l","/:^l","/=I","/:I","/:-I","/=-I","/=^I","/:^I",
"/=oI","/:oI","\\=|","\\:|","\\:-|","\\=-|","\\=^|","\\:^|","\\=o|","\\:o|",
"\\=l","\\:l","\\:-l","\\=-l","\\=^l","\\:^l","\\=I","\\:I","\\:-I","\\=-I",
"\\=^I","\\:^I","\\=oI","\\:oI")
iconstate = "skeptical2"
sad_skeptical2
smileys = list("/=(","/:(","/:-(","/=-(","/=^(","/:^(","/=\[","/:\[","/:-\[",
"/=-\[","/=^\[","/:^\[","/:<","/:-<","/=-<","/=^<","/:^<","/:o\[","/:o(",
"/=o\[","/=o(","\\=(","\\:(","\\:-(","\\=-(","\\=^(","\\:^(","\\=\[","\\:\[",
"\\:-\[","\\=-\[","\\=^\[","\\:^\[","\\:<","\\:-<","\\=-<","\\=^<","\\:^<",
"\\:o\[","\\:o(","\\=o\[","\\=o(")
iconstate = "sad/skeptical2"
happy_skeptical2
smileys = list("/=)","/:)","/:-)","/=-)","/=^)","/:^)","/=)","/:]","/:-]",
"/=-]","/=^]","/:^]","/:>","/:->","/=->","/=^>","/:^>","/:o]","/:o)",
"/=o]","/=o)","\\=)","\\:)","\\:-)","\\=-)","\\=^)","\\:^)","\\=]","\\:]",
"\\:-]","\\=-]","\\=^]","\\:^]","\\:>","\\:->","\\=->","\\=^>","\\:^>",
"\\:o]","\\:o)","\\=o]","\\=o)")
iconstate = "happy/skeptical2"
wink_grin
smileys = list(";D",";-D",";^D")
iconstate = "wink/grin"
tongue2
smileys = list("=p",":p",":-p","=-p","=^p",":^p","=þ",":þ",":-þ","=-þ","=^þ",":^þ",
"=oþ",":oþ","=op",":op")
iconstate = "tongue2"
tongue
smileys = list("=P",":P",":-P","=-P","=^P",":^P","=oP",":oP")
iconstate = "tongue"
grin
smileys = list("=D",":D",":-D","=-D","=^D",":^D")
iconstate = "grin"
wink
smileys = list(";)",";-)",";^)",";\]",";-\]",";^\]",";>",";->",";^>",
"^_-","-_^","^.-","-.^","O_-","-_O","O.-","-.O","o_-","-_o","o.-","-.o",
"0_-","-_0","0.-","-.0")
iconstate = "wink"
sad_wink_a
smileys = list(";(",";-(",";^(",";\[",";-\[",";^\[",";<",";-<",";^<")
iconstate = "sad wink_a"
wink_tongue2
smileys = list(";p",";-p",";^p",";þ",";-þ",";^þ",";oþ",";op")
iconstate = "wink/tongue2"
wink_tongue
smileys = list(";P",";-P",";^P",";oP")
iconstate = "wink/tongue"
smile
smileys = list("=)",":)",":-)","=-)","=^)",":^)","=\]",":\]",":-\]","=-\]",
"=^\]",":^\]","=\]",":>",":->","=->","=^>",":^>","=o>",":o>","=o)","=o\]",
":o)",":o\]")
iconstate = "smile"
neutral
smileys = list("=|",":|",":-|","=-|","=^|",":^|","o_o","o.o","=o|",":o|",
"=l",":l",":-l","=-l","=^l",":^l","=I",":I",":-I","=-I","=^I",":^I","=oI",":oI")
iconstate = "neutral"
sad_a
smileys = list("=(",":(",":-(","=-(","=^(",":^(","=\[",":\[",":-\[","=-\[",
"=^\[",":^\[",":<",":-<","=-<","=^<",":^<",":o<",":o(",":o\[","=o<","=o(","=o\[")
iconstate = "sad_a"
thoughtful_wink
smileys = list(";|",";-|",";^|",";o|",";l",";-l",";^l",";ol",";I",";-I",";^I",";oI")
iconstate = "thoughtful wink"
weird
smileys = list(":S","=S","=oS",":oS",":-S","=-S",":^S","=^S",":oS","=oS","=}",
"={",":}",":{",":@","@.@",":?","=?",":-?","=-?",":^?","=^?",":o?","=o?")
iconstate = "weird"
surprised_a
smileys = list("=o",":o",":-o","=-o","=^o",":^o","=O",":O",":-O","=-O","=^O",
":^O","o.O","O.o","O_o","o_O","=oo",":oo","=oO",":oO",":0",":-0","=0","=-0",
":^0","=^0",":o0","=o0")
iconstate = "surprised_a"
anime_smile
smileys = list("^_^")
iconstate = "anime smile"
anime_O
smileys = list("^.^")
iconstate = "anime O"
anime_sleepy
smileys = list("-_-","-.-")
iconstate = "anime sleepy"
uncertain
smileys = list(":/",":\\","=/","=\\",":o\\",":o/","=^/","=^\\",":^/",":^\\",
"=-/","=-\\",":-/",":-\\")
iconstate = "uncertain"
XD
smileys = list("XD","xD","Xd")
iconstate = "XD"
shades
smileys = list("8-)")
iconstate = "Shades 8-)"
Zipped
smileys = list(":X")
iconstate = "Zipped shut :X"
Sumo
smileys = list("-_-")
iconstate = "Sumo -_-"
Crying
smileys = list(":'(")
iconstate = "Crying :'("
Angel
smileys = list("0:)")
iconstate = "Angel 0:)"
BigEyes
smileys = list("0.0")
iconstate = "0.0"

proc/s_smileys(text as text)
var/smiley/smiley
for(smiley in s_smileys)
var/B
for(B in smiley.smileys)
if(!findtext(text,B)) continue

var/image/O = new
O.icon = 's_smileys.dmi'
O.icon_state = smiley.iconstate
text = replaceWord(text, B, "<IMG CLASS=\"icon\" SRC=\"\ref[O.icon]\" \
ICONSTATE=\"
[smiley.iconstate]\">")
del O
return(text)


/*--------------------*/

//Credit to: Spuzzum
//Contributed by: Spuzzum
//Dependency of: alphabetics snippet (Spuzzum)

//This snippet of code replaces *words* in a sentence.
// In this fashion, it avoids accidentally replacing letters
// that belong to other words. For example, if you had this
// string:

// I am very intelligent.

// ...and you decided to replace the word I, you'd get:

// x am very xntellxgent

// ...if you used the replacetext snippet. With this snippet,
// you'd get:

// x am very intelligent

// which is hopefully what the doctor ordered.

#include "alphabetics.dm"

proc/replaceword(string, search, replace)
if(!findtext(string, search)) return string
var/tmp/string_len = lentext(string)
var/tmp/search_len = lentext(search)
var/tmp/replace_len = lentext(replace)

var/tmp/last_char = 0 //0 -- non-alphabetic, 1 -- alphabetic or numeral
//anything in the ignore list is assumed to be a part of a word
var/list/ignores = list("'","1","2","3","4","5","6","7","8","9",",",".")

for(var/pos = 1, pos <= string_len-search_len+1, pos++)
var/char = copytext(string, pos, pos+1) //determine if this is a break between words
if(isalphabetic(char) || ignores.Find(char) || findtext(search, char))
if(!last_char)

var/following_char = " " //defaults to a space in case it's the end of the string
if(pos+search_len <= string_len) //avoid going out of bounds
following_char = copytext(string, pos+search_len, pos+search_len+1)

//if the search string is followed by a non-alpha, we have a complete word
if(!isalphabetic(following_char))
//now, if the word matches, replace it appropriately!
if(cmptext(copytext(string, pos, pos+search_len), search))
string = copytext(string, 1, pos) + replace + copytext(string, pos+search_len)
string_len += replace_len - search_len

last_char = 1 //toggle the state of the last character
else if(last_char) last_char = 0
return(string)

proc/replaceWord(String, Search, Replace)
if(!findText(String, Search)) return String
var/tmp/String_len = lentext(String)
var/tmp/Search_len = lentext(Search)
var/tmp/Replace_len = lentext(Replace)

var/tmp/last_Char = 0 //0 -- non-alphabetic, 1 -- alphabetic or numeral
//anything in the ignore list is assumed to be a part of a word
var/list/Ignores = list("'","1","2","3","4","5","6","7","8","9",",",".")

for(var/Pos = 1, Pos <= String_len-Search_len+1, Pos++)
var/Char = copytext(String, Pos, Pos+1) //determine if this is a break between words
if(isalphabetic(Char) || Ignores.Find(Char) || findText(Search, Char))
if(!last_Char)

var/following_Char = " " //defaults to a space in case it's the end of the string
if(Pos+Search_len <= String_len) //avoid going out of bounds
following_Char = copytext(String, Pos+Search_len, Pos+Search_len+1)

//if the search string is followed by a non-alpha, we have a complete word
if(!isalphabetic(following_Char))
//now, if the word matches, replace it appropriately!
if(cmpText(copytext(String, Pos, Pos+Search_len), Search))
String = copytext(String, 1, Pos) + Replace + copytext(String, Pos+Search_len)
String_len += Replace_len - Search_len

last_Char = 1 //toggle the state of the last character
else if(last_Char) last_Char = 0
return(String)

/*-----------------*/
//Credit to: Spuzzum
//Contributed by: Spuzzum

//REPLACE_TEXT PROC
// This is a text-replacement function. There is one
// included in the Deadron library, but this one avoids
// using lists and relies upon strings directly, making
// it more rapid (presumably).

//Updated version: will never be thrown into an infinite loop!


proc/replacetext(string, search, replace)
if(!findtext(string, search)) return string
var/string_len = lentext(string)
var/search_len = lentext(search)
var/replace_len = lentext(replace)

for(var/pos = 1, pos <= string_len, pos++)
if(cmptext(copytext(string, pos, pos+search_len), search))
string = copytext(string, 1, pos) + replace + copytext(string, pos+search_len)
string_len += replace_len - search_len
return(string)

proc/replaceText(String, Search, Replace)
if(!findText(String, Search)) return String
var/String_len = lentext(String)
var/Search_len = lentext(Search)
var/Replace_len = lentext(Replace)

for(var/Pos = 1, Pos <= String_len, Pos++)
if(cmpText(copytext(String, Pos, Pos+Search_len), Search))
String = copytext(String, 1, Pos) + Replace + copytext(String, Pos+Search_len)
String_len += Replace_len - Search_len


The problem is in the part with BigEyes as a smiley.
one....dont copy demo's thats called a rip. and two i'm not even going to look at the code and think its because of the . in o.o.
In response to CodingSkillz2 (#1)
thats not a demo its called a Library, you make the little tick mark in the tree to show you want it in your game

Try changing the iconstate ="0.0" to something else and then in the icon change it also...that might work maybe its the "." that mess's it up
I think the problem is that the smiley surbrised_b already has the "O.O" trigger for producing a smiley. Maybe if you remove that from the surprised_b smiley definition, it might work.

~X
In response to Xooxer (#3)
also the sumo and anime sleepy. -_-.