FindObjectOfType
Posted: Sat Jan 14, 2012 1:58 pm
Future Boy! has some code attached to certain verbs, like >READ ABOUT <TOPIC>, where if you don't specify the book object, it looks around for the nearest object of type "book."
Now, honestly, I haven't added this to any of my own games yet, but there have been times when I've been playing other people's games where I do a lazy short command and am slightly annoyed that the game doesn't assume I mean the NPC I am talking to or whatever.
So, I think most of us would agree that Future Boy! went above-and-beyond in parser-helping, but I thought it'd be good for people to be aware of the feature anyway. I made a page for the specific routine it uses, FindObjectOfType here: http://hugo.gerynarsabode.org/index.php ... jectOfType
I made another version of it that uses attributes in case people want to check for the nearest-living-thing* (since NPCs can be type "character" or "female_character"):
http://hugo.gerynarsabode.org/index.php ... fAttribute
* It occurs to me that someone could just have code like the following:
Still, I'll keep the attribute version up in case that is what somebody is looking for one day.
Now, honestly, I haven't added this to any of my own games yet, but there have been times when I've been playing other people's games where I do a lazy short command and am slightly annoyed that the game doesn't assume I mean the NPC I am talking to or whatever.
So, I think most of us would agree that Future Boy! went above-and-beyond in parser-helping, but I thought it'd be good for people to be aware of the feature anyway. I made a page for the specific routine it uses, FindObjectOfType here: http://hugo.gerynarsabode.org/index.php ... jectOfType
I made another version of it that uses attributes in case people want to check for the nearest-living-thing* (since NPCs can be type "character" or "female_character"):
http://hugo.gerynarsabode.org/index.php ... fAttribute
* It occurs to me that someone could just have code like the following:
Code: Select all
local a
a = higher( FindObjectOfType(character,location), FindObjectOfType(female_character, location) )
if a
...