Author Topic: Questions about ROL and anyword  (Read 1124 times)

0 Members and 1 Guest are viewing this topic.

Offline claudehuggins

Questions about ROL and anyword
« on: August 07, 2016, 05:59:44 PM »
Note: I'm posting this in the AGI board because that's what I'm using, but I believe this could also apply to SCI. Let me know if this needs to be somewhere else.

I am attempting to create a statement in my global logic that gives a sarcastic quip when the player starts a sentence with "why" (since I noticed a lot of my playtesters were doing so facetiously). My attempt in doing this led to an issue that I may find the solution to useful in other situations.

My instinct was to use
Code: [Select]
if(said("why","rol")) {
print("Because that's just how the world works, %s3.");
}
Which worked fine for phrases like "why talk to the wizard" and other lines consisting of words in the WORDS.TOK file.

My issue is, if someone were to type something like "why are you so dumb", I'd want the quip to appear even though words like "dumb" and "so" aren't defined. Typing that with this setup gets the generic "I don't know X" message.

Is there a way to detect the presence of a word in a line, and flat-out ignore the entire rest of the line if it is found?

EDIT: I also considered using anyword after noticing the large block of code used for handling bad words, but upon doing a test having the engine parse a series of unknown words with a bad word among them, it doesn't see the word at all.
EDIT 2: Corrected my syntax in the example code because it was bugging me
« Last Edit: August 07, 2016, 06:04:58 PM by claudehuggins »


A while ago, at a block party I found myself socially trapped at, I thought to myself: I need a t-shirt that says, "I'd rather be programming".

Offline OmerMor

Re: Questions about ROL and anyword
« Reply #1 on: August 08, 2016, 01:38:34 PM »
I'm not knowledgeable enough in AGI, but perhaps Sierra's official documentation could be of help:
http://sciprogramming.com/community/index.php?topic=1617.0

Offline lskovlun

Re: Questions about ROL and anyword
« Reply #2 on: August 09, 2016, 10:32:40 PM »
OK, so I've given this a bit of thought, not knowing anything about AGI and not having tested anything.
If this is possible at all, I think you need to look at re-parsing with the use of a helper string.
According to Omer's docs, there is a "%w1" directive that can be put in a string to refer to the first word in the input line. So I'm thinking along the lines of
Code: [Select]
parse("%w1");
if(said("why")) {
print("Because that's just how the world works, %s3.");
}
Note that this will interfere with your ordinary input handling (it will make the full input line inaccessible), so it needs to be done after all other input handling code. This approach can also be used in SCI to inject an input line into the ordinary input handler code, but if I were doing this in SCI, I would use wordFail/syntaxFail/semanticFail instead. SCI also doesn't have the %wn directive, nor a word.to.string command (another potentially useful feature).

Offline lance.ewing

Re: Questions about ROL and anyword
« Reply #3 on: February 25, 2017, 12:25:18 PM »
EDIT: I also considered using anyword after noticing the large block of code used for handling bad words, but upon doing a test having the engine parse a series of unknown words with a bad word among them, it doesn't see the word at all.

I realise that its been months since this was discussed, but it caught my eye this morning, mainly because I think that the solution I'm about to propose works in the original AGI interpreter but not in my C# interpreter  :(

Code: [Select]
if ((said("why") || said("why","anyword") || said("why","anyword","anyword") || said("why","anyword","anyword","anyword") || said("why","anyword","anyword","anyword","anyword"))) {
  print("Because that's just how the world works.");
  unknown_word_no = 0;
}

It seems to work from the testing I've done, but obviously only up to however many "anyword" variations you include. What I've noticed is that "anyword" matches both recognised words and unrecognised words. My interpreter is currently only matching recognised words, so I'll have to fix that now.
« Last Edit: February 25, 2017, 12:28:18 PM by lance.ewing »


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

Page created in 0.083 seconds with 23 queries.