Initially, this worked great, but I found that I could trick the game into showing me that there were only 4 newspaper objects with a command like >GET 5 NEWSPAPERS.
This also reminded me of an older WIP where, in a room full of golf balls, a tester tried the command >GET 1000 GOLF BALLS. Now, I'm not going to go code a thousand golf ball objects, but ever since then, I was a little disappointed that I couldn't do more to give the illusion that the game could handle such a command.
Anyhow, now that I have roodylib and a better understanding of how things work, I thought I'd take a swing at the problem. I tracked down the code in ParsePluralObjects that interprets the number in the command line. It calls WordIsNumber, which matches the word with a simple select-case that handles numbers "1"/"one" through "10"/"ten". I added code so it also calls StringToNumber, so it can now also handle 11-32767 (it can't handle the word version of these numbers but I figured that was a lost cause).
My first hurdle was that this section of code checks the word array for numbers twice, supposedly so that Hugo can understand commands like >GET TWO OUT OF THE THREE CHICKENS. My StringToNumber-enhanced routine can't be called twice like that, so I had to throw the "<blank> out of <blank>" code out.
It was easy enough to find the code in plural_class object where it prints a "There are only X objects here."-type command when you refer to too many, and it was also easy enough to change it to disregard the number of actual-objects-there.
Still, I thought there was another important number in the equation. There's the number you want the player to think is there. In the above example, I *don't* want >GET 1000 PAPERS to have the same reply as >GET 5 PAPERS. To handle this, I added a couple new properties to the plural_class object. One is called imaginary_plurals. It holds the number the plural class is supposed to have*.
* The type of plural object that uses these properties are going to be largely scenery. They aren't actually going to be picked up or interacted with to any large degree. We're only doing this to make responses sound smarter.
The other one is called over_max. It just holds the response the player will see when he refers to more objects than the imaginary plurals number.
Let's take a look at my finished newspaper object:
identical_class newspapers "newspapers"Hopefully, that'll all make sense in the end. There's a good chance I'm breaking more than I realized, as plural class stuff seems to juggle a lot. Anyhow, I think this *will* call for a new Roodylib upload. People can expect it soon enough.
{
plural_of paper1, paper2, paper3, paper4
noun "newspapers" "papers"
single_noun "newspaper" "paper"
imaginary_plurals 12
over_max
"Even with all of the apartments and homes on your street, you'd
be lucky to find more than a dozen papers in the near vicinity."
}
I have to say, this looks very impressive. I will look forward to seeing how it works in the game.
ReplyDeleteI'm a little confused about the Roodylib version. It looks like I downloaded an update on October 21st.
I uploaded a new version yesterday, so I *think* yours should be outdated (by how much, it's hard to say). I made a page on Hugo by Example to list the latest version number: http://hugo.gerynarsabode.org/index.php?title=Roodylib
DeleteYou can find the version number of your roodylib suite by opening roodylib.h and looking at #ifset VERSIONS.
As you can see, on the HbE page, I'm also starting to keep changelog-y information. I still have a ways to go in terms of making releases as clear as possible, I know. I'm still a bit uncertain what my options are when it comes to choosing a source version control or whatever that'd be both free and not share editing rights with the whole entire world (don't want to wake up one morning to find that somebody has gone and given roodylib 178 near-useless attributes).
Thanks. My confusion is partly due to my own disorganization; I have lots of different versions of roodylib, newmenu, and some of your other ones in my Library folder, in my Hugo directory. I just downloaded the latest, so I'll use that one for Hugo Comp.
DeleteJust a reminder that when you #set VERSIONS, the compiler list will print the versions of all of the extensions you're using (well, the ones I've contributed to, anyway).
DeleteI've started listing most-recent version numbers at: http://hugo.gerynarsabode.org/index.php?title=Category:Library_Contributions
Hopefully that'll make it a little easier to get organized.