ID:269057
 
How do I make the normal say verb, except, have it where if there are certain things inside the string, Then I can be able to replace them with something else?
A little while ago, Gazoot posted a proc that did just that!

proc
//Replace all instances of [find] in [string] with [replace]
stringreplace(string,find,replace)
var/pos = findtext(string, find)
if(!pos)
return string
else
return copytext(string,1,pos) + replace + stringreplace(copytext(string,pos+length(find),0), find, replace)


Using this proc, if you wanted to say, parse for forum id numbers, you could create a proc like this:

proc
//Take the characters after [word] in [string]
//and link them to the forum.
idparse(string as text,word="id:")
var/pos = findtext(string, word)
if(pos)
var
space = findtext(string, " ", pos)
text = copytext(string, pos+length(word), space)

string = stringreplace(string, "[word][text]", "<a href='http://developer.byond.com/forum/index.cgi?action=message_read&id=[text]&single=1'>[word][text]</a>")
return string


We would use idparse() like so:

mob/verb/Say(T as text)
world << "[idparse(T)]"