FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

Allowing "Comment Recorded" in Hugo

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
Merk



Joined: 22 Nov 2004
Posts: 192
Location: Wichita, KS

PostPosted: Mon Nov 05, 2007 9:12 am    Post subject: Allowing "Comment Recorded" in Hugo Reply with quote

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:
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:
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
Back to top
View user's profile Send private message Visit poster's website
Merk



Joined: 22 Nov 2004
Posts: 192
Location: Wichita, KS

PostPosted: Mon Nov 05, 2007 9:28 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Mon Nov 05, 2007 10:27 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Merk



Joined: 22 Nov 2004
Posts: 192
Location: Wichita, KS

PostPosted: Mon Nov 05, 2007 3:48 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
FartFag
Guest





PostPosted: Sat Jan 12, 2008 12:05 am    Post subject: Reply with quote

POWNED!!!
Back to top
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Sat Jan 19, 2008 9:07 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
pinback



Joined: 27 Apr 2002
Posts: 12029

PostPosted: Sun Jan 20, 2008 10:47 am    Post subject: Reply with quote

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.
_________________
Above all else... We shall go on... And continue!
Back to top
View user's profile Send private message Visit poster's website
Bainespal



Joined: 09 Jul 2010
Posts: 151

PostPosted: Thu May 26, 2011 3:35 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Mon May 30, 2011 10:37 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Bainespal



Joined: 09 Jul 2010
Posts: 151

PostPosted: Tue May 31, 2011 4:20 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Tue May 31, 2011 5:05 pm    Post subject: Reply with quote

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:

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:

   if word[1] = "script"
      transcript_is_on = true
Back to top
View user's profile Send private message AIM Address
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Wed Jun 01, 2011 8:07 pm    Post subject: Reply with quote

Whoa, that's a pretty solid little hack right there! Nice work, Roody!
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Bainespal



Joined: 09 Jul 2010
Posts: 151

PostPosted: Thu Jun 02, 2011 6:13 pm    Post subject: Reply with quote

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. :)
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended