Unwanted periods

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

Bainespal
Posts: 151
Joined: Fri Jul 09, 2010 8:59 am

Unwanted periods

Post by Bainespal »

This is a small aesthetic problem, but I can't solve it on my own. I have two rooms in my game that need to display different names depending on certain conditions. In both cases, my code works as expected except that it puts a period after the room title in both the status line and the main window. I have no idea where the period is coming from, and it doesn't matter whether or not I use "print" or just have a double-quoted string.

Here's an example of the code (using different strings than in my game):

Code: Select all

room hillside
{
  name
  {
      if night_flag = true
      {  "A Shadowy Incline";  }
      else
      {  "A Sunny Hillside";  }
  }
}
The game would print "A Shadowy Incline." or "A Sunny Hillside."

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

Post by Roody_Yogurt »

This took some looking into, but eventually I found the answer in the Pirate Adventure source. You want this:

Code: Select all

room hillside
{
  name
  {
      if night_flag = true
         return "A Shadowy Incline"
      else
         return "A Sunny Hillside"
  }
} 
Personally, I'm a little unclear on what are the rules about returning strings from object properties. The other day, I was unsuccessfully trying to return a printed string from a cant_go property or something, so I share your confusion.

My only guess is that since object.name isn't treated like a regular string, wackiness ensues.

EDIT: I have updated the HxE page to reflect this: http://hugo.gerynarsabode.org/index.php?title=Name

Bainespal
Posts: 151
Joined: Fri Jul 09, 2010 8:59 am

Post by Bainespal »

Wow... I'm surprised that this little bug is such an obscure problem.
Roody_Yogurt wrote:The other day, I was unsuccessfully trying to return a printed string from a cant_go property or something, so I share your confusion.
That's also good to know. If I have to have a conditional can't-go message (which I'm contemplating at the moment), I won't bother putting the condition in a cant_go property; I'll trap it in "location DoGo" instead.

Thanks for doing all the digging. It's surely a good thing that this is being documented in HxE.

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

Post by Roody_Yogurt »

Well, you still can do this:

Code: Select all

cant_go  {
              if object = se_obj, s_obj
                       {
                       "That'd put you in the lake!"
                       return true
                       }
              elseif object = e_obj
                       {
                       "There's a brick wall there."
                       return true
                       }
              else
                       return false
              }

                       
I just was unsuccesful trying things like 'return "There's a brick wall there."'

Post Reply