I didn't know that room names automatically get capitalized both in the main window and in the status line until I recently used the CanGo library extension.
This is good default behavior, since we may want to use room names in other contexts, as CanGo.h does. Best practice would be always to enter room names in lower-case.
I can see a difficulty. If you want room names capitalized in book-title style, only the first word is automatically capitalized. You could capitalize the important words in the strings themselves, but then other code (including CanGo.h) will inappropriately print the caps in a sentence.
Room names automatically capitalized
Moderators: Ice Cream Jonsey, joltcountry
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
I wish I could get notifications every time someone starts a thread in this base! Just saw this today.
The good news is that the groundwork for this is halfway supported in Roodylib already. DescribePlace calls Rlibmessage for the room name printing, at which point you can copy the name to a string and use the string capitalization (right now, one only exists to capitalize the first letter of every word but I could throw one together to capitalize by book title rules).
Unfortunately, the same thing doesn't currently exist for PrintStatusLine, but you're right, I should throw a message hook in there.
I'll throw together some code as soon as I can.
The good news is that the groundwork for this is halfway supported in Roodylib already. DescribePlace calls Rlibmessage for the room name printing, at which point you can copy the name to a string and use the string capitalization (right now, one only exists to capitalize the first letter of every word but I could throw one together to capitalize by book title rules).
Unfortunately, the same thing doesn't currently exist for PrintStatusLine, but you're right, I should throw a message hook in there.
I'll throw together some code as soon as I can.
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
So, an updated version of roodylib with the necessary message replacement calls is now up here (and will be in the next official release):
https://bitbucket.org/roody_yogurt/hugo ... ?at=master
Next is some code showing how to capitalize every first letter in a game where room names are all lowercase for extensions like CanGo. First, before roodylib.h is included, set the following:
Then add this to your game:
Of course, you could also just alter the messages so the first letters of rooms are *not* capitalized if that floats your boat. I took a look at book title capitalization rules, and it really seems like more of a hassle to code than it is worth. In a game where you really want room names to be *right*, it might be worth it to give those rooms an extra name property with the proper capitalization and alter the messages to print from the other property instead.
Also, you'll notice that my above code doesn't do anything about ", in the <parent> of player" text so if your game has stuff like that, you might have to alter the code to accommodate that to your tastes.
https://bitbucket.org/roody_yogurt/hugo ... ?at=master
Next is some code showing how to capitalize every first letter in a game where room names are all lowercase for extensions like CanGo. First, before roodylib.h is included, set the following:
Code: Select all
#set USE_STRING_MANIPULATION
Code: Select all
replace NewRlibMessages(r, num, a, b)
{
select r
case &DescribePlace
{
select num
case 1
{
if not (FORMAT & DESCFORM_I) or (verbroutine ~= &MovePlayer and
verbroutine ~= &DoLookAround and a = location)
print "\n";
else
{
local col
col = display.cursor_column
if system(61) or not display.hasgraphics
--col
if col
"\n";
}
Font(BOLD_ON)
CapitalizeRoom(a)
! print capital a.name;
! Print ", in <something>" if necessary
if location = a and player not in a
{
if parent(player).prep
print ", "; parent(player).prep; " ";
elseif parent(player) is platform
print ", "; ON_WORD; " ";
else
print ", "; IN_WORD; " ";
print Art(parent(player))
}
print newline
Font(BOLD_OFF)
}
}
case &WriteStatus
{
if not location
print "\_";
elseif not light_source
print "\_In the dark";
else
{
print "\_";
CapitalizeRoom(location)
! print capital location.name;
}
}
case else : return false
return true ! this line is only reached if we replaced something
}
array roomname[100]
routine CapitalizeRoom(place)
{
text to roomname
print place.name;
text to 0
CapitalizeEveryFirstLetter(roomname)
StringPrint(roomname)
}
Also, you'll notice that my above code doesn't do anything about ", in the <parent> of player" text so if your game has stuff like that, you might have to alter the code to accommodate that to your tastes.
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
So, this thread got me thinking that I should add some message routine calls to my versions of CanGo, too, but taking a look at them, it looks like I already put a mechanic in them for alternate text, an additional room property called cango_name. Just have it return the text you want rooms to be listed as from other rooms. You can also turn it into a property routine so it returns different text depending on different circumstances.
The only thing is that they use a SKIP routine which clashes with a local variable I added to Roodylib recently, so I changed the Roodylib local variable so now there's a new version of roodylib.h at the above link.
Anyhow, here are the links for my versions of CanGo:
Can Go Lite (works basically the same as the original with some more efficient code):
http://hugo.gerynarsabode.org/index.php ... anGoLite.h
New Can Go (my version with additional capabilities):
http://hugo.gerynarsabode.org/index.php?title=NewCanGo
Both could probably use better documentation so I apologize for that. Ask me if you have any questions.
The only thing is that they use a SKIP routine which clashes with a local variable I added to Roodylib recently, so I changed the Roodylib local variable so now there's a new version of roodylib.h at the above link.
Anyhow, here are the links for my versions of CanGo:
Can Go Lite (works basically the same as the original with some more efficient code):
http://hugo.gerynarsabode.org/index.php ... anGoLite.h
New Can Go (my version with additional capabilities):
http://hugo.gerynarsabode.org/index.php?title=NewCanGo
Both could probably use better documentation so I apologize for that. Ask me if you have any questions.
-
- Posts: 151
- Joined: Fri Jul 09, 2010 8:59 am
That makes sense. In a more complicated situation, you might need the printed names for rooms to differ in other ways from their status-line descriptors.Roody_Yogurt wrote:In a game where you really want room names to be *right*, it might be worth it to give those rooms an extra name property with the proper capitalization and alter the messages to print from the other property instead.
Perfect, that should allow for more dynamic room listing than the Scott Adams-type exit list provided by the original CanGo code.Roody_Yogurt wrote:it looks like I already put a mechanic in them for alternate text, an additional room property called cango_name. Just have it return the text you want rooms to be listed as from other rooms. You can also turn it into a property routine so it returns different text depending on different circumstances.
To be honest though, I'm too tired to look at your code right now. I used CanGo.h for a quick and dirty mock-up of a level design for a Source Engine mod that I'm working on with two other students in my videogame design class. (It's a custom Portal 2 campaign.) Valve's level editor is a miserable piece of software -- it barely works on my hardware even after I upgraded to a better used laptop, it crashes and freezes, it has unpredictable bugs, it's complicated and almost completely undocumented. I'd rather work with Hugo any day, and hopefully I'll find the time and motivation to do so again eventually.