Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Sun Aug 24, 2003 1:46 pm
Trouble with room descriptions |
I'm working on a script for automapping the infamous Achaea. I've been able to successfully pull out 99% of the room names and even the room exits. I don't care about mobs or items in a room, but I would like to parse out the description for my database.
The troubles I having revolve around having several different colored lines in the description. The room description itself is a simple gray, but there are also mobs and items that show up dark cyan and other people show up light cyan. I've been trying all sorts of triggers and functions to clean up the unwanted parts of the description, but I can't seem to get it quite right.
First off, I can't use %pos to look for ANSI color codes in a matched line, even with the ANSI option checked. Second, I have been having trouble with commas in the strings, which I believe I have worked around successfully by using "%1" instead of just %1. Third, sometimes there is no carriage return on the line between the color changes and sometimes there is one. Fourth if a roomname has more than one period in it (e.g. Ulangi and Co. Trading Post.), I only get up to the second period, but if I try anchor the trigger at the end of the line, I screw up on lines like "Prelatorian Highway. (road)".
Here's a room that I was having particular trouble mapping and basically shows an example of everything I want to parse out. First, the ANSI codes version:
%e[32m4416h, 3912m %e[0mcex-%e[30;43mlook%e[0m%e[33mEntrance to Inbhir Ness. %e[0mYou stand before a large wooden gate, steadied on either side by large stone pillars. The door appears to be exceptionally thick, and it is barred with iron bands, preventing entry by force. The words Inbhir Ness have been skillfully carved into it, giving name to what lies beyond, and even the stone pillars feature an inherent precision. To either side of the path, sheer cliffs loom above you, allowing no other mode of entry.%e[36m Spreading its majestic golden %e[0m%e[36mwings, a giant eagle searches the ground with piercing eyes. A dwarf sentry %e[0m%e[36mstands at attention, his eyes searching for strangers. %e[1;36mDefender Grethor Ta'sa %e[0m%e[1;36mis here. He wields a shining steel longsword in each hand. %e[0;33mYou may enter the %e[0m%e[33mwilderness map from here. %e[0m%e[1;34mYou see exits leading north and south.%e[0m
Then, the colorized version (black is really gray and lime green is really light cyan):
4416h, 3912m cex-look
Entrance to Inbhir Ness.
You stand before a large wooden gate, steadied on either side by large stone pillars. The door appears to be exceptionally thick, and it is barred with iron bands, preventing entry by force. The words Inbhir Ness have been skillfully carved into it, giving name to what lies beyond, and even the stone pillars feature an inherent precision. To either side of the path, sheer cliffs loom above you, allowing no other mode of entry. Spreading its majestic golden wings, a giant eagle searches the ground with piercing eyes. A dwarf sentry stands at attention, his eyes searching for strangers. Defender Grethor Ta'sa is here. He wields a shining steel longsword in each hand. You may enter the wilderness map from here. You see exits leading north and south.
Also, here's the script that I'm using so far...
#CLASS {Mapping}
#ALIAS onroomcreate {#if (@mapwild) {#noop %roomcol( ,yellow);mapwild = 0};#if (@mapshop) {#noop %roomcol( ,brown);mapshop = 0};#if (@mapsewer) {#noop %roomcol( ,orange);mapsewer = 0}}
#VAR roomname {} {}
#VAR roomexits {} {}
#VAR roomnaming {1} {1}
#VAR exitstemp {west, and northwest.[0m}
#VAR mapwild {0} {0}
#VAR mapshop {0} {0}
#VAR mapsewer {0} {0}
#VAR roomdesc {} {}
#TRIGGER "roomtrig" {%e[33m(*).*$} {#if (%line =~ "*It is now the *") {#state roomtrig 0;#set roomtrig -1 0;#abort 1};#if (@roomnaming) {roomname = %1;roomname = %concat( @roomname, ".");roomdesc = "";roomexits = "";#t+ desctrig};roomnaming = 0;#tag Name @roomname} "" {notrig|color}
#COND {*} {roomdesc = %trim( %concat( @roomdesc, " ", %stripansi( %line)))} {looplines|param=99|notrig|color|line=7}
#TRIGGER "exitstrig" {%e[1;34mYou see (*)} {roomnaming = 1;roomexits = %concat( "You see ", "%1");#if (%pos( ., @roomexits)) {#tag Exit @roomexits}} "" {color}
#COND {%e[1;34m(*)} {exitstemp = %1;roomexits = %stripansi( %concat( @roomexits, " ", @exitstemp));#if (%pos( ., @roomexits)) {#tag Exit @roomexits;#state exitstrig 0;#set exitstrig -1 0}} {looplines|param=2|color}
#TRIGGER {There is no exit in that direction.} {#nodir;#nomap}
#TRIGGER {There is a door in the way.} {#nodir;#nomap}
#TRIGGER {Your mount slips and fall on the ice as you try to leave.} {#nodir;#nomap}
#TRIGGER {The forest seems to close up before you and you are prevented from moving that } {}
#COND {way.} {#nodir;#nomap} {within|param=1}
#TRIGGER {There's water ahead of you. You'll have to swim in that direction to make it } {}
#COND {through.} {#nodir;#nomap} {within|param=1}
#TRIGGER {You begin to ford the waters *.} {#nomap}
#TRIGGER {You relax your muscles and attune yourself to your Master Crystal feeling its } {}
#COND {vibrations draw your soul.} {#nomap} {within|param=1}
#TRIGGER {Now now, don't be so hasty!} {#nodir;#nomap}
#TRIGGER {WARES} {mapshop = 1} "" {case|verbatim}
#TRIGGER {enter the wilderness} {mapwild = 1} "" {case|verbatim}
#TRIGGER {sewer grate} {mapsewer = 1} "" {case}
#TRIGGER {A wall blocks your way.} {#nodir;#nomap}
#TRIGGER "desctrig" {{%e[36m|%e[1;36m}(*)$} {#state roomtrig 0;#set roomtrig -1 0;roomdesc = %trim( %leftback( @roomdesc, %len( %stripansi( %1))));#t- desctrig} "" {nocr|prompt|notrig|color}
#STW {%ansi( high, magenta)Mapper: %ansi( yellow)Name = @roomname;%ansi( high, orange)Desc = @roomdesc;%ansi( high, green)Exits = @roomexits}
#CLASS 0
Any help on this at all will be greatly appreciated! Thanks. |
|