Double indented short_descs

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

Double indented short_descs

Post by Bainespal »

I've had a long standing problem with the standard Library short description for NPCs ("Whoever is here."). That message is being indented twice, standing out starkly against the single-indented long_desc of the room and short_descs of objects. This problem showed up in my other unfinished Hugo game, and right now it's the only thing I would ideally like to correct in World Builder before sending Release 2 to the IFDB/IF Archive. However, I'll still release the new version even if I can't fix this aesthetic bug.

Here is an example of the problem:

Code: Select all

Your workshop
  Automatons scurry to and fro in the complex of interconnected machinery, which churns and whirls across the vast convex surface of the Sphere.
    Hugor is here.
As you can see, "Automatons" at the beginning of the room description is indented two spaces, but "Hugor" is indented four spaces. The same problem happens with the other NPC in World Builder.

The short_desc properties of both NPCs contain a routine that returns a string if a condition is met, or else returns "false" to produce the standard Library message. That code seems to work well, except for this problem.

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Re: Double indented short_descs

Post by Tdarcos »

Bainespal wrote: The short_desc properties of both NPCs contain a routine that returns a string if a condition is met, or else returns "false" to produce the standard Library message. That code seems to work well, except for this problem.
Is it a naked quoted string or is it preceded by "print "?
Try sticking a semicolon on the end of the message string being displayed first. If it gives you an error, put a print statement in front of it. When there are multiple strings, in some cases Hugo presumes a \n on the end of earlier ones, forcing a newline. Using a semicolon warns the compiler not to force a newline after the string. This is exactly how the print statement in Basic works.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

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

Post by Roody_Yogurt »

The problem is that ShortDescribe, the routine that checks to see if an object has a short_desc property or should get a default one, has this bit of code:

Code: Select all

	if &obj.short_desc
		Indent
The ampersand means that it checks if there is any code at all in the short_desc property- not just that it returns false- it'll do the Indent, I think.

Ok, I've been looking into this problem for several minutes now. I think the easiest answer is to never return false and fake generic no-short_desc messages yourself, depending on the conditions at hand.

Just the same, I will think on this a bit more.

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

Post by Roody_Yogurt »

Just kidding! There IS an easier way!

Define the constant AFTER_PERIOD before hugolib.h is included:

Code: Select all

constant AFTER_PERIOD ""
Then, in those cases where short_descs return false, also change the global variable override_indent to true.

(Took me a while to realize that AFTER_PERIOD is used literally nowhere else in the Hugo library)[/code]

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

Re: Double indented short_descs

Post by Bainespal »

Tdarcos wrote: Is it a naked quoted string or is it preceded by "print "?
Try sticking a semicolon on the end of the message string being displayed first. If it gives you an error, put a print statement in front of it. When there are multiple strings, in some cases Hugo presumes a \n on the end of earlier ones, forcing a newline. Using a semicolon warns the compiler not to force a newline after the string. This is exactly how the print statement in Basic works.
That's a very good thought, but not quite the issue at hand. Thanks for the observation. I too learned much the same through trial and error.

Roody, thanks again for the solution. I'm sorry to bother you so much. ;) I never would have known about the existence of AFTER_PERIOD.

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

Post by Roody_Yogurt »

I feel obnoxious that I post to this base so much (and so excitedly reply to things), but other than that, I am happy to help!

Post Reply