From bcde188954e1afe97a337517386408aca7315021 Mon Sep 17 00:00:00 2001 From: Vatiken Date: Fri, 21 Jun 2013 20:59:42 -0700 Subject: [PATCH] Added a 'toupper' command to dg_scripts. DG Script command: %string.toupper% This will capitalize the first letter of a string. --- changelog | 3 +++ src/dg_variables.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/changelog b/changelog index 5868df7..6dd4e2f 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,9 @@ TbaMUD is currently being developed by The Builder Academy. If you need any help, find any bugs, or have ideas for improvement please stop by TBA at telnet://tbamud.com:9091 or email rumble@tbamud.com --Rumble @ +[Jun 21 2013] - Vatiken + Added 'toupper' as a dg_script command to capitalize the first letter + of a string. [Apr 11 2013] - Rumble Added color parsing to wiznet. [Apr 10 2013] - Rumble diff --git a/src/dg_variables.c b/src/dg_variables.c index 8c44d32..f96e3ef 100644 --- a/src/dg_variables.c +++ b/src/dg_variables.c @@ -179,6 +179,11 @@ int text_processed(char *field, char *subfield, struct trig_var_data *vd, if (!str_cmp(field, "strlen")) { /* strlen */ snprintf(str, slen, "%d", (int)strlen(vd->value)); return TRUE; + } else if (!str_cmp(field, "toupper")) { /* toupper */ + char *upper = vd->value; + if (*upper) + snprintf(str, slen, "%c%s", UPPER(*upper), upper + 1); + return TRUE; } else if (!str_cmp(field, "trim")) { /* trim */ /* trim whitespace from ends */ snprintf(tmpvar, sizeof(tmpvar)-1 , "%s", vd->value); /* -1 to use later*/