FindObjectOfType

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

Roody_Yogurt
Posts: 2179
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

FindObjectOfType

Post by Roody_Yogurt »

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:

Code: Select all

local a
a = higher&#40; FindObjectOfType&#40;character,location&#41;, FindObjectOfType&#40;female_character, location&#41; &#41;
if a
   ...
Still, I'll keep the attribute version up in case that is what somebody is looking for one day.