Help Menu

Dear all,

I’m trying to do a classic Infocom-style hint menu. Code seems intuitive, like

topHintMenu: TopHintMenu 'Hints'
;

+HintMenu 'General'
;

++ Goal 'Text'
    [
        'Text'
    ]
;

etc. But how do I, erm… “activate” it? Like, with just this the game compiles, and typing “help” results in a runtime error “invalid index operation - this type of value cannot be indexed”, and typing “hint/s” results in “Sorry, no hints are currently available. Please check back later.”.

Thanks and kind regards,
Grues

2 Likes

You have to create an action, or modify an existing action, and have said action display your menu.

2 Likes

Hm. Doesn’t work the way I try it.

DefineIAction(Help)
    execAction(){
        TopHintMenu.display();
    }
;

VerbRule(Help) 'help': HelpAction
    verbPhrase = 'help'
;

topHintMenu: TopHintMenu 'Hints'
;

+HintMenu 'Test 1';

++ Goal 'Topic 1'
    [
        'Answer 1',
        'Answer 2'
    ]
;

+HintMenu 'Test 2';

opens the menu but it’s completely empty. :frowning:

1 Like

Try the lower-case call:

topHintMenu.display();

I think you need to call from the object you made; not its class prototype. It’s probably empty because you’re calling the class prototype, which is just the default empty state.

2 Likes

the upper/lowercase of the first character of the call is one of the main differences between adv3 and adv3Lite…

Best regards from Italy,
dott. Piergiorgio.

1 Like

Still doesn’t work. :frowning:

DefineIAction(Help)
    execAction(){
        topHintMenu.display();
    }
;

VerbRule(Help) 'help': HelpAction
    verbPhrase = 'help'
;

topHintMenu: TopHintMenu 'Hints'
;

+HintMenu 'Test 1';

++ Goal 'Topic 1'
    [
        'Answer 1',
        'Answer 2'
    ]
;

+HintMenu 'Test 2';

Compiles, but typing “help” leads to a completely empty help menu without and selection to choose from. I’m completely lost. :

1 Like

Is the position in the source code of relevance? Like, does the help object need to be positioned above or below the gameMain object?

Before I crack open the docs, is this for Adv3 or Adv3Lite?

Adv3. In Learning TADS 3 it’s chapter 18.2 on page 298.

1 Like

Currently reviewing the documentation (I usually work with Adv3Lite, but the skills carry over if I have the docs for Adv3 open).

I don’t think so.

It seems really weird that a dev would need to declare object instances but call display() on the class itself, and not its object instance, but I’ll take your word for it, as you have more Adv3 experience than I do.

1 Like

Okay, so I noticed in this guide that the TopHintMenu is contained within the “about” menu, but after looking through the library reference for Adv3, it looks like TopHintMenu should work perfectly fine as a starting point, too.

I’m gonna keep poking around and replying with updates. Note that I’m doing this on a smartphone, so I don’t really have a good way to test theories right now.

1 Like

Oh, I’m more than happy to test out anything for you, but not today as it’s bedtime already here.

(As an adult, I’m so bold as to arbitrarily postpone bedtime a little to work on some IF stuff. :wink:

1 Like

I’m not seeing a definition for HelpAction anywhere in the docs, fwiw.

Sleep well~ :grin:

2 Likes

Nor sure what you are seeing exactly, but note that Goals default to Undiscovered state (which in turn hides the Menu encapsulating it, absent other active hints). You probably want to add

++ Goal 'Text'
    [
        'Text'
    ]
    goalState = OpenGoal // add this!
;

to ensure it presents when using hints. Note there are a variety of openWhenX properties to get more reactive to game state (ie openWhenTrue, openWhenSeen, etc). I think that’s the only change needed from your original code just to get it going though.

Note also, unless you have a fuller use for the keyword help you can just add it to vocab for the hint verb:

modify VerbRule(Hint) 'hint' | 'hints' | 'help' : ;

Note the weird colon-semicolon syntax, because of macro expansion.

Hope that helps!

3 Likes

It works! Thanks so much!! <3

3 Likes