FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

Room names automatically capitalized

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
Bainespal



Joined: 09 Jul 2010
Posts: 151

PostPosted: Tue Apr 01, 2014 11:46 am    Post subject: Room names automatically capitalized Reply with quote

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.
Back to top
View user's profile Send private message
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Thu Apr 03, 2014 11:41 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Thu Apr 03, 2014 1:02 pm    Post subject: Reply with quote

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-code-lab/src/7674b682f853b70dec8aa78e022b162db18f9d7a/roodylib/roodylib.h?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:
#set USE_STRING_MANIPULATION


Then add this to your game:
Code:
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)
}


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.
Back to top
View user's profile Send private message AIM Address
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Thu Apr 03, 2014 5:23 pm    Post subject: Reply with quote

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?title=CanGoLite.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.
Back to top
View user's profile Send private message AIM Address
Bainespal



Joined: 09 Jul 2010
Posts: 151

PostPosted: Fri Apr 04, 2014 6:44 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended