Allowing "Comment Recorded" in Hugo

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

Merk
Posts: 192
Joined: Mon Nov 22, 2004 3:19 pm
Location: Wichita, KS
Contact:

Allowing "Comment Recorded" in Hugo

Post by Merk »

Bert Byfield posted a slick Hugo mod to the newsgroup, for allowing the parser to recognize "*" as a comment line (instead of defaulting to an unrecognized message from the parser).

I took that and worked it into some code that should be pretty easy to plug into any Hugo program. If you're already doing a REPLACE on NewParseError or NewVMessage, you'd want to just include that code in your existing ones. If not, just copy as-is.

Kent -- any chance of getting this into the base Hugo Lib? That'd be cool... :)

It may need some testing. It *seems* to work okay for me, but I haven't done tremendous testing on it yet. Here it is, though.

First, you need to add a "global" variable to the program (somewhere near the top, after your #includes:

Code: Select all

global transcript_is_on = false
And then, just put all of this somewhere in your program. Voila! Now commands that start with an asterisk are recognized as comment lines!

Code: Select all

replace DoScriptOnOff
{
    if word[2] = "on" or words = 1
    {
        if (transcript_is_on) or (not scripton)
            VMessage(&DoScriptOnOff, 1) ! "Unable to begin..."
        else
        {
            transcript_is_on = true
            VMessage(&DoScriptOnOff, 2) ! "Transcription on."
        }
    }
    elseif word[2] = "off"
    {
        if (not transcript_is_on) or (not scriptoff)
            VMessage(&DoScriptOnOff, 3) ! "Unable to end..."
        else
        {
            transcript_is_on = false
            VMessage(&DoScriptOnOff, 4) ! "Transcription off."
        }
    }
}

replace NewParseError(errornumber, obj)
{
    string(_temp_string, parse$, 1) !get 1st byte of input
    if (_temp_string[0] = '*')
    {
        if (transcript_is_on)
            VMessage(&DoScriptOnOff, 5) ! Comment recorded!
        else 
            VMessage(&DoScriptOnOff, 6) ! Comment not recorded!
        return true
    }
}

replace NewVMessages(r, num, a, b)
{
    select r
    case &DoScriptOnOff
    {
        select num
        case 1
        {
            if (transcript_is_on)
                print "Transcription is already on."
            else
                print "Unable to begin transcription."
        }
        case 2:  print "Transcription on."
        case 3
        {
            if (not transcript_is_on)
                print "Transcription is not currently on."
            else
                print "Unable to end transcription."
        }
        case 4:  print "Transcription off."
        case 5: print "Comment recorded!"
        case 6: print "Comment not recorded!"
        return true
    }
    return false !So all other VMessages work as-is.
}
Last edited by Merk on Tue Nov 06, 2007 6:05 am, edited 2 times in total.

Merk
Posts: 192
Joined: Mon Nov 22, 2004 3:19 pm
Location: Wichita, KS
Contact:

Post by Merk »

I think there are a couple ways it could be improved.

First, is there some system flag that already lets you know if a transcript is on or not? I figure there might be, but I don't have my Hugo Book in front of me at the moment. If so, that could replace the "transcript_is_on" global.

Second, when a transcript is turned on, it might be good to dump the "version" info (like how zcode and/or Tads does currently). I don't think there's any default/consistent version info, though, so it might require a stub "PrintVersion" in the lib, where the user could do a "replace" on it with specific version information. Maybe the stub could show, at least, the Hugo and lib versions.

User avatar
Ice Cream Jonsey
Posts: 28877
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Post by Ice Cream Jonsey »

Cool, thanks for the heads-up. Of all the dumb things Google Groups does, one of the dumbest is stripping anything in brackets. People use them for a reason and I absolutely cannot fathom the logic. The whole thing is a broken mess and I've gotten to the point where I gloss over a lot of rec.arts.int-fiction because I'm just mainly interested in Hugo stuff. I should check in through Forte Agent each night.

(Of course, Bert may not have announced this with a [Hugo] tag, but still.)

Regarding the mod: I'm not sure if there is a transcript global, but there must be something so the game knows whether or not to throw "Transcript on" versus "Transcript off" at you.
the dark and gritty...Ice Cream Jonsey!

Merk
Posts: 192
Joined: Mon Nov 22, 2004 3:19 pm
Location: Wichita, KS
Contact:

Post by Merk »

There is, but it's in the transcript verbroutine (which you can see at work in my "replace" above). Basically, if you turn off the script, it *tries* to turn it off (using the system command). If it succeeds, you get a message that the script is now off, otherwise a failure. If you try to turn it on, it *tries*, and if it succeeds, you get the message otherwise an error.

So at the script level, in the lib, it's never actually checking to see if the script was on or off already. That's why I had to add a global so I'd be able to customize the "comment recorded" messages (plus, I can then use it to know in advance whether or not the transcript is on already, and customize the error message too).

What I'm thinking is maybe a SYSTEM value that indicates if it's already on or not. If there is one, I'll update that code to use it instead of a new global.

FartFag

Post by FartFag »

POWNED!!!

User avatar
Ice Cream Jonsey
Posts: 28877
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Post by Ice Cream Jonsey »

I am just posting to get that smarmy a-hole off the "last post by" value, so I don't have to see it when I go to this website.

Here is a STATE OF THE UNION ADDRESS for my experiences with Hugo:

- It does everything I want it to do
- I am out of questions, and for the most part, know how to implement everything I care about
- I am going to program in this language for big projects for the next several years, because it is absolutely intoxicating to be at the 90% percentile of a computer programming language.

This also means there will probably be very few posts here going forward, as I am not asking questions of anyone. But still. Hugo kicks ass, and I totally dig it.
the dark and gritty...Ice Cream Jonsey!

User avatar
pinback
Posts: 17672
Joined: Sat Apr 27, 2002 3:00 pm
Contact:

Post by pinback »

Well, there will be no posts here after March 31, so I'd suggest if any of you have questions or have an upcoming project you're expecting to have difficulty with, please air them out now.
I don't have to say anything. I'm a doctor, too.

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

Post by Bainespal »

I added this code to my game, and it is much appreciated! I miss this feature in Inform games that I've played (I believe Inform 6 had it built-in, but 7 doesn't).

Unfortunately, the code doesn't seem to work perfectly. I have a transcript file that plainly records "Comment not recorded!" each time I made a comment. However, I then specifically made a transcript to test this code, and it worked. When I made the script file that displays the glitch, the program had been running in the Debugger for several turns already, and I think I had already used the HugoFix command to transport the player object. I'm not sure what the exact conditions were that caused the problem.

If I learn anything else about this bug (assuming it wasn't caused by the Debugger or the HugoFix library commands that were used before starting the transcript, which is probably possible), I'll let you guys know.

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

Post by Roody_Yogurt »

That is odd. I'd be interested in hearing if you can replicate that at some point.

In any case, just because practically every game should have this, I put this thing into "library contribution" format over at Hugo by Example. You can find it here.

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

Post by Bainespal »

I discovered why the code was printing the wrong message in my first transcript. It seems to get confused when a transcript is begun before the game is restart. My guess is that the transcript_is_on global, as well as whatever Hugo uses to keep track of transcripts being on or off, gets reset during a restart.

This is actually a serious problem. When I'm making a transcript of the first session of playing an IF game, I almost always issue a RESTART command immediately after starting the transcript, in order to capture whatever opening text is displayed before the first command prompt. I suspect many players might do the same.

Roody, I just copied my short test transcripts demonstrating all this to you in a PM. I'll send them to anyone else who is also interested.

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

Post by Roody_Yogurt »

Hmm, good catch.

Unfortunately, I can't think of a "clean" fix, but I did come up with a workaround. Globals may be reset when a game is restarted, but I've found out the hard way that the word array is not so we can use that to our advantage.

Add the following code:

Code: Select all

replace DoRestart
{
	VMessage(&DoRestart, 1)                  ! "Are you sure?"
	GetInput
	if YesorNo = true
	{
		if transcript_is_on
			word[1] = "script"
		if not restart
			VMessage(&DoRestart, 2)  ! "Unable to restart."
	}
}
And then add this code to your init routine:

Code: Select all

	if word[1] = "script"
		transcript_is_on = true

User avatar
Ice Cream Jonsey
Posts: 28877
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Post by Ice Cream Jonsey »

Whoa, that's a pretty solid little hack right there! Nice work, Roody!
the dark and gritty...Ice Cream Jonsey!

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

Post by Bainespal »

That seems to fix everything, even the library's confusion over the state of the transcript after a restart! That's definitely a clever solution. Now we're holding our own with the other IF systems!

Great work. :)

Post Reply