Author Topic: Need help adding text to parser  (Read 268 times)

0 Members and 1 Guest are viewing this topic.

Offline klownstein

Need help adding text to parser
« on: May 19, 2021, 04:13:57 PM »
I am working on an AGI project and want to implement a hot key to add "ask about" to the text parser a la Quest for Glory II. In QFG2, the player can press Ctrl-A and the parser writes "ask about" as if the player had written those words into the parser.

I know how to set up controllers to trigger when the player presses Ctrl-A, but am finding it harder to write anything into the parser and am not sure if it is even possible.

The closest I have been able to get is by using the following command:

get.string(s1, ">ask about ", 22, 0, 40);

This will appear to do what I want, but is not the same as just writing "ask about" in the parser because it stops the game from cycling, prevents you from erasing the words "ask about", because they are not actually in the parser, and requires extra work to provide responses to the question (rather than using the if(said("words")) command, I am having to set and compare strings AND have it work when the player actually writes "ask about" into the parser, more than twice the effort and feels very clunky).

Does anyone know where the information that is written into the parser before the player presses <enter> is stored? Is it in a string somewhere that I can access? Is there any way to modify that information?

What I have works, but does anyone know if it is possible to write words into parser? It would make life so much easier if I could do it that way. Something like:

if(controller(c49){
    cancel.line(); //clears all words from the parser if player has something written there
    MAGIC.COMMAND("ask about");//writes the words "ask about" into the parser
    accept.input();//allows player to type like normal with the words "ask about" having previously been written
}

Ideas?

-klownstein





Offline gumby

Re: Need help adding text to parser
« Reply #1 on: May 19, 2021, 06:27:30 PM »
In SCI, you can do this by appending the string into the buffer before showing the parser input box.  Is something similar possible with AGI?
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline AGKorson

Re: Need help adding text to parser
« Reply #2 on: May 19, 2021, 07:53:12 PM »
Unfortunately, the input line is not accessible in AGI through commands. The input line buffer is actually maintained in memory at the end of the code segment, just before the main memory heap - it's part of the data overlay, agidata.ovl.

But there are no commands that let you interact directly with that buffer. The get.string command uses a different buffer.

You might be able to fake it by changing the input prompt to include 'ask about', and then get input as usual. This might be a start:
Code: [Select]
if (controller(c49) {
  set.string(inputPrompt, ">ask about ");
  cancel.line();
  accept.input();
  set(f123);
}

I did a quick test of this and it works. When you test for 'said' input, you can check the flag; if it's set, you can respond appropriately. Then reset your input prompt (and the flag). You will also need to make sure you put the check for this flag before any other said tests to avoid unwanted results.

A limitation of this approach is that you can't backspace over 'ask about', because it's part of the input prompt. It might be possible to work around that too, but I'd have to think about it some more.


« Last Edit: May 20, 2021, 10:25:19 AM by AGKorson »

Offline klownstein

Re: Need help adding text to parser
« Reply #3 on: May 19, 2021, 10:04:24 PM »
Thanks for the quick replies. I'd spent quite a few hours over the past several days pouring over the documentation and reading through the WinAGI help files to see if I could get a little more control over the parser before I felt like I'd hit a dead end and needed to ask the experts. It sounds like the closest option will be some type of work around with a small compromise in expectations. Even so, it will be much, much better than having to type "ask about" a zillion times. Thanks again for the responses and the help!
-klownstein

Offline MusicallyInspired

Re: Need help adding text to parser
« Reply #4 on: May 20, 2021, 04:38:53 PM »
Unfortunately, the input line is not accessible in AGI through commands. The input line buffer is actually maintained in memory at the end of the code segment, just before the main memory heap - it's part of the data overlay, agidata.ovl.

But there are no commands that let you interact directly with that buffer. The get.string command uses a different buffer.

You might be able to fake it by changing the input prompt to include 'ask about', and then get input as usual. This might be a start:
Code: [Select]
if (controller(c49) {
  set.string(inputPrompt, ">ask about ");
  cancel.line();
  accept.input();
  set(f123);
}

I did a quick test of this and it works. When you test for 'said' input, you can check the flag; if it's set, you can respond appropriately. Then reset your input prompt (and the flag). You will also need to make sure you put the check for this flag before any other said tests to avoid unwanted results.

A limitation of this approach is that you can't backspace over 'ask about', because it's part of the input prompt. It might be possible to work around that too, but I'd have to think about it some more.

Would this solution work with the Hercules Monochrome driver that displays a pop-up input dialogue like SCI does?
Brass Lantern Prop Competition

Offline Kawa

Re: Need help adding text to parser
« Reply #5 on: May 21, 2021, 06:11:51 AM »
Would this solution work with the Hercules Monochrome driver that displays a pop-up input dialogue like SCI does?
You mean this input dialogue box?



Maybe if the game is detecting that it's running on Herc and set the same prompt to "Enter input" instead of ">". If it's the engine itself, you'd be SOL. And looking at LSL1 and ScummVM, it seems you would in fact be just that.

Offline AGKorson

Re: Need help adding text to parser
« Reply #6 on: May 21, 2021, 11:29:53 AM »
To be clear, in MSDOS, running on a monochrome monitor, AGI completely ignores the input prompt (i.e. it doesn't matter what you set string s0 to). The input box is hard coded to include the phrase "ENTER COMMAND" centered at the top of the box, with  the single input line that displays only the input text and the cursor just below. No input prompt is included, but you can change the cursor character (using set.cursor.char).

The buffer for the input text is in the same location as for any other video mode, but it is just as inaccessible. So you can't modify it through code, in HGC mode, or any other mode*.

@Kawa, btw, in your image the input box has the caption "Enter input" not "ENTER COMMAND". I assume that screen shot is from SCUMMVM then? Because in all the MSDOS versions I have, the caption is "ENTER COMMAND".

I don't know a lot about SCUMMVM, but my experience has been that the modern interpreters don't accurately capture all the nuances of the original DOS interpreter, because errors and edge cases tend to be ignored in modern systems (they don't let you overrun memory, for example). So there are things you can do in MSDOS (or using DOSBox) that modern interpreters just can't handle.

*I have a 'secret project' that I'm just about ready to release that will demonstrate some of the cool things you can do with the original DOS interpreter by taking advantage of some of their poor coding practices in AGI. (Spoiler: the functionality that klownstein is looking for is easily doable if you know the secret!)






Offline Kawa

Re: Need help adding text to parser
« Reply #7 on: May 21, 2021, 12:26:56 PM »
@Kawa, btw, in your image the input box has the caption "Enter input" not "ENTER COMMAND". I assume that screen shot is from SCUMMVM then? Because in all the MSDOS versions I have, the caption is "ENTER COMMAND".
You assumed correctly. But in the end it doesn't really matter to the bigger point, does it?


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.102 seconds with 24 queries.