LATER LATER EDIT: I posted some updated code later in the thread, and am pasting it here now too over the old. The code block here should be good to go.
LATER EDIT: this code doesn’t cope with every situation perfectly. I suspect that an HTML tag is getting split somehow, but I haven’t looked into it yet. The only bug I’ve noticed so far is where the only pre-room report is an implicit announcement… the closing tag gets lost somewhere and the rest of the desc is in bold.
Second edit: I think <.p> markers are playing the same kind of havoc. [end edit]
I’m sharing a snippet of code to address what I expect will be a problem for more people than just myself. Whether I’m playing games myself, or reading transcripts of others playing my game, I find that it is very easy for the player to overlook reports/printed text that comes before a room title. In adv3, this text comes from things like travelDesc, enteringRoom, reportBefore, following NPCs and more.
This experimental solution allows the gamemaker to either auto-embolden the first several words of the pre-room-title reports, or to auto-insert extra spacing or eye-catching symbols before the report, according to the author’s taste.
Unfortunately this is only available for adv3, because I’m not aware of any abilities that adv3Lite has to buffer and rearrange outputted text.
//THIS USED TO BE SOMETHING ELSE... I've pasted in what I hope to be more correct
//code from the lower post
preRoomTransform: TranscriptTransform
useBold = true
boldLength = 20
insertTxt = 'o=o=o=o=o=o=o=o=o=o\n'
//* Look for reports' messageText_ that has printable characters outside of angle bracket delimiters
notInTag = static R'(%s|%v)*((<langle>[^>]+<rangle>)(%s|%v)*)*<AlphaNum|Punct>|^(%s|%v)*<AlphaNum|Punct>'
wordEnd = static R'%>'
lastWordEnd = static R'<AlphaNum>%s*((<langle>[^>]+<rangle>)(%s|%v)*)*$'
firstWordStart = static R'(%s|%v)*((<langle>[^>]+<rangle>)(%s|%v)*)*<AlphaNum>'
getPrintableLength(txt) {
local startIdx = rexMatch(firstWordStart,txt) ?? 1;
local res = rexSearch(lastWordEnd,txt);
local endIdx = res ? res[1] : txt.length;
return endIdx - startIdx + 1;
}
addTags(txt,closeIdx?) {
local startIdx = (rexMatch(firstWordStart,txt) ?? 1);
local endIdx, res;
if(closeIdx) res = rexSearch(wordEnd,txt,closeIdx);
else res = rexSearch(lastWordEnd,txt);
endIdx = (res ? res[1] : txt.length) + 1;
txt = txt.splice(endIdx,0,'</b>');
return txt.splice(startIdx,0,'<b>');
}
applyTransform(tr,vec) {
//* The first report will typically be a CommandSepAnnouncement. If we find a room
//* title report, and it's not second in line, we will check the intervening reports for
//* one which has printable characters. We'll draw attention to it with bold or symbols.
local bef = vec.indexWhich({f:f.messageText_=='<.roomname>'});
if(bef && bef>2) {
//* Found a room title. Now look for a printable report before it.
local rep = vec.valWhich({f: dataType(f.messageText_)==TypeSString &&
//* I chose to skip implicit reports and object announcment reports as candidates
//* for emboldening. So that in
//* - - - - - -
//* (first getting out of the iron maiden)
//* You leave the horrific chamber to the west, doing something very
//* noteworthy on the way...
//*
//* o=o=o ROOM TITLE o=o=o
//* This is the next room, where you probably missed the bit about
//* doing something noteworthy on your way here.
//* - - - - - - -
//* we will not embolden the implicit report, but instead will embolden
//* "You leave the horrific...". If you *want* the implicits etc. to be candidates
//* for emboldening, comment out the following line.
!f.messageText_.find('<.assume>') &&
rexMatch(notInTag,f.messageText_)!=nil &&
vec.indexOf(f)<bef });
if(rep) {
//* Found a printable report before the room title
if(useBold) {
//* We will embolden words at the beginning of the string
//* First determine our length in terms of visible characters, and not tags and spaces
local rlen = getPrintableLength(rep.messageText_);
local vidx = vec.indexOf(rep);
if(rlen<boldLength && rlen>7) {
//* Whole message is shorter than our boldLength: tags at beginning and end
rep.messageText_ = addTags(rep.messageText_);
}
else if(rlen<8) {
//* The message we found is probably a single word. Embolden part of the next
//* message as well, if there is one.
rep.messageText_ = addTags(rep.messageText_);
local rep2 = vec.valWhich({f:
dataType(f.messageText_)==TypeSString &&
rexMatch(notInTag,f.messageText_)!=nil &&
vec.indexOf(f)<bef &&
vec.indexOf(f)>vidx});
if(rep2) rep2.messageText_ = addTags(rep2.messageText_,boldLength-rlen);
}
//* Else find soonest word ending after boldLength to insert </b>
else rep.messageText_ = addTags(rep.messageText_,boldLength);
}
else {
//* Insert either spaces or symbols before the report to draw attention.
//* Try to find the first printable character for insertion point so we don't
//* swallow any leading <.p>'s etc.
local startIdx = (rexMatch(firstWordStart,rep.messageText_) ?? 1);
rep.messageText_.splice(startIdx,0,insertTxt);
}
}
}
;
modify CommandTranscript
transforms_ = static inherited + preRoomTransform
;