Makes the preloader apply text macros: Re-engineering (#24614)

* Add apply_text_macros

* Make the map loader use text macros

* Cleanup
This commit is contained in:
Cyberboss
2017-03-09 15:22:34 -05:00
committed by oranges
parent 27bb35decc
commit 2f4fb6f68a
2 changed files with 59 additions and 0 deletions

View File

@@ -554,3 +554,60 @@ var/list/binary = list("0","1")
var/list/tosend = list()
tosend["data"] = finalized
log << json_encode(tosend)
//Used for applying byonds text macros to strings that are loaded at runtime
/proc/apply_text_macros(string)
var/next_backslash = findtext(string, "\\")
if(!next_backslash)
return string
var/leng = length(string)
var/next_space = findtext(string, " ", next_backslash + 1)
if(!next_space)
next_space = leng - next_backslash
if(!next_space) //trailing bs
return string
var/base = next_backslash == 1 ? "" : copytext(string, 1, next_backslash)
var/macro = lowertext(copytext(string, next_backslash + 1, next_space))
var/rest = next_backslash > leng ? "" : copytext(string, next_space + 1)
//See http://www.byond.com/docs/ref/info.html#/DM/text/macros
switch(macro)
//prefixes/agnostic
if("the")
rest = text("\the []", rest)
if("a")
rest = text("\a []", rest)
if("an")
rest = text("\an []", rest)
if("proper")
rest = text("\proper []", rest)
if("improper")
rest = text("\improper []", rest)
if("roman")
rest = text("\roman []", rest)
//postfixes
if("th")
base = text("[]\th", rest)
if("s")
base = text("[]\s", rest)
if("he")
base = text("[]\he", rest)
if("she")
base = text("[]\she", rest)
if("his")
base = text("[]\his", rest)
if("himself")
base = text("[]\himself", rest)
if("herself")
base = text("[]\herself", rest)
if("hers")
base = text("[]\hers", rest)
testing("Substituted macro(\\[macro]) in string([string]). Result: \"[base + rest]\"")
. = base
if(rest)
. += .(rest)

View File

@@ -436,6 +436,8 @@ var/global/dmm_suite/preloader/_preloader = new
var/value = attributes[attribute]
if(islist(value))
value = deepCopyList(value)
if(istext(value))
value = apply_text_macros(value)
what.vars[attribute] = value
use_preloader = FALSE