intfiction.org
https://www.intfiction.org/forum/

TopicAction and adv3lite [Solved]
https://www.intfiction.org/forum/viewtopic.php?f=10&t=25247
Page 1 of 1

Author:  Karona [ Sat Jan 06, 2018 6:50 pm ]
Post subject:  TopicAction and adv3lite [Solved]

I seem to be missing something fundamental about how to create a TopicAction with adv3lite, but for the life of me I cannot figure out what it is. Here is some relevant sample code:

Code:
gameMain: GameMainDef
    initialPlayerChar = me
;

tSummer: Topic 'summer';

VerbRule(Remember)
   ('remember') topicDobj
   : VerbProduction
   action = Remember
   verbPhrase = 'remember / remembering (what)'
   missingQ = 'what do you want to remember'
;

DefineTopicAction(Remember)
   execAction(cmd)
   {
      if(gTopicMatch == tSummer)
      {
         "{I} remember{s/ed} what {i} did last summer. ";
      }
      else
      {
         "{I} {do} not remember that. ";
      }
   }
;

startRoom: Room 'Bedroom'
    "Not the most original setting for an IF work, but a great place
    to write one. "
;

+ me: Actor 'Karona;;; her'   
    isFixed = true       
    person = 2
    contType = Carrier
    globalParamName = 'me'
;

And this is what happens after I compile and run it:

Rant: show
>remember last summer
You do not remember that.

What I would have liked to have seen in response was, "You know what you did last summer."

How do I make this work?

Author:  tomasb [ Sun Jan 07, 2018 11:20 am ]
Post subject:  Re: TopicAction and adv3lite

I don't know details about adv3lite. That said, the word "last" you used in the command is neither part of the grammar nor part of the topic so it can't match.

Author:  Karona [ Sun Jan 07, 2018 2:44 pm ]
Post subject:  Re: TopicAction and adv3lite

tomasb wrote:
That said, the word "last" you used in the command is neither part of the grammar nor part of the topic so it can't match.

You are right!

Unfortunately the problem remains even if the right command ("remember summer") is used.

I have found a "duct tape solution" (if I may steal a phrase DavidW used on ifMUD) by changing the relevant line of code to the following:

Code:
if(gTopicText == 'summer')

Of course, it would be more satisfying to have a solution that involves interacting with the topic only as opposed to the topic's text. So if anyone has other ideas, I would be happy to hear them.

Author:  tomasb [ Tue Jan 09, 2018 2:20 am ]
Post subject:  Re: TopicAction and adv3lite

Ok, now I thought about it more. Topic object itself doesn't do anything itself, conversations are modelled in a way that individual responses are presented as objects contained in some TopicDatabase (which is for example Actor or Consultable). You would need to follow the source code in library to understand it - on Actor there is a method findBestResponse(prop, topic) which in turn calls getBestMatch in actor state and if not found the in Actor itself and that will go though topics in database and find best match. It all starts by calling handleTopic on Actor, for example handleTopic(&askForTopics, gCommand.iobj.topicList);

On the other hand conversation commands involve some target Actor to whom the player character is tallking and in your case the player character talks to himself when he remembers something, so in your case you would need to adapt handling accordingly. And thats the point where I've realized that adv3lite already has something similar. In thoughts.t library file there is a mechanism handling "think about topic", which allows you to create ThoughtManager object and locate several Thought objects in it (which are used same way as other TopicEntries, so you program them same way as conversation topics matching things and topics), like (untested):

Code:
myThoughts: ThoughtManager;

+ Thought @tSummer
    "{I} remember{s/ed} what {i} did last summer. "
;

+ DefaultThought
    "{I} {do} not remember that. "
;


Now you can "think about last summer" and need to extend grammar of the ThinkAbout command to also allow "remember", probably something like:
Code:
VerbRule(ThinkAbout2)
    'remember' topicDobj
    : VerbProduction
    action = ThinkAbout
    verbPhrase = 'remember/remembering (what)'
    missingQ = 'what do you want to remember'
;

Author:  Karona [ Tue Jan 09, 2018 11:33 pm ]
Post subject:  Re: TopicAction and adv3lite

tomasb wrote:
In thoughts.t library file there is a mechanism handling "think about topic", which allows you to create ThoughtManager object and locate several Thought objects in it (which are used same way as other TopicEntries, so you program them same way as conversation topics matching things and topics), like (untested):

This is the sort of solution I would have wanted to find, had I known what to look for. Thank you! Thank you!

Page 1 of 1 All times are UTC - 6 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/