Room names automatically capitalized

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:smile: :sad: :eek: :shock: :cool: :-x :razz: :oops: :evil: :twisted: :wink: :idea: :arrow: :neutral: :mrgreen:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Room names automatically capitalized

by Bainespal » Fri Apr 04, 2014 6:44 pm

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.
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: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.
Perfect, that should allow for more dynamic room listing than the Scott Adams-type exit list provided by the original CanGo code.

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.

by Roody_Yogurt » Thu Apr 03, 2014 5:23 pm

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.

by Roody_Yogurt » Thu Apr 03, 2014 1:02 pm

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:

Code: Select all

#set USE_STRING_MANIPULATION
Then add this to your game:

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
					&#123;
						if parent&#40;player&#41;.prep
							print ", "; parent&#40;player&#41;.prep; " ";
						elseif parent&#40;player&#41; is platform
							print ", "; ON_WORD; " ";
						else
							print ", "; IN_WORD; " ";
						print Art&#40;parent&#40;player&#41;&#41;
					&#125;
					print newline
					Font&#40;BOLD_OFF&#41;
				&#125;
		&#125;
		case &WriteStatus
		&#123;
			if not location
				print "\_";
			elseif not light_source
				print "\_In the dark";
			else
			&#123;
				print "\_";
				CapitalizeRoom&#40;location&#41;
	!			print capital location.name;
			&#125;
		&#125;
		case else &#58; return false
   return true ! this line is only reached if we replaced something
&#125;

array roomname&#91;100&#93;

routine CapitalizeRoom&#40;place&#41;
&#123;
	text to roomname
	print place.name;
	text to 0
	CapitalizeEveryFirstLetter&#40;roomname&#41;
	StringPrint&#40;roomname&#41;
&#125;
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.

by Roody_Yogurt » Thu Apr 03, 2014 11:41 am

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.

Room names automatically capitalized

by Bainespal » Tue Apr 01, 2014 11:46 am

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.

Top