Ok, I don't completely understand what problem you're running into, but I know that strings in verb grammar are a big headache. You can use the "string" grammar token, but that forces the player to use quotation marks and I haven't had much success in getting the player to use them.
Anyhow, I'm going to go over the entire thing without specifically addressing your problem, but then I'll go back and change it to work off of two arrays.
First off, the grammar:
Code: Select all
verb "type"
* string "on" object DoType
* word "on" object DoType
(so that both >TYPE PASSWORD and >TYPE "PASSWORD" work)
Now a DoType routine that checks against password "swordfish":
Code: Select all
array typing[10] ! allow 9 letter password
routine DoType
{
local len
"You type \"";
if parse$ ~= -16 ! -16 seems to be the default value
print parse$;
else
print word[2];
"\" on the computer. A box pops up that says, \"";
len = string(typing,parse$,9) ! write parse$ to array
if not StringDictCompare(typing,"swordfish") or word[2] = "swordfish" ! returns 0 if no difference
"CORRECT!\""
else
"WRONG!\""
return true
}
Still, we want the game to accept any wrong word when typing passwords, yet we keep on running into that damn, "I don't know the word 'blah'" response. To get around that, we'll put something into NewParseError:
Code: Select all
replace NewParseError(errornumber,obj)
{
select errornumber
case 1 : {
if word[1] = "type"
{
DoType
main ! fake a turn
return true
}
return false
}
case else : return false
return true
}
The downside to this workaround is that we have to fake a turn passing, so if the player tries to UNDO, they'll actually UNDO the
previous turn. All in all, string input in Hugo is definitely something I'd like to see improved so we wouldn't have to resort to this.
Ok, so that's all that. Now, as far as
your particular situation goes, changing the StringDictCompare line to:
Code: Select all
if StringCompare(typing, random_password_string_array) = 0
... should work.
Of course, your question was specifically about printing, which makes me think that at least one of the string arrays was filled incorrectly. Hopefully, some of the grammar stuff above helps with that. Otherwise, maybe post some sample code and we can take a look at it.
EDIT: missed a 'return false' in the NewParseErrors routine above.
Ok, I don't completely understand what problem you're running into, but I know that strings in verb grammar are a big headache. You can use the "string" grammar token, but that forces the player to use quotation marks and I haven't had much success in getting the player to use them.
Anyhow, I'm going to go over the entire thing without specifically addressing your problem, but then I'll go back and change it to work off of two arrays.
First off, the grammar:
[code]
verb "type"
* string "on" object DoType
* word "on" object DoType[/code]
(so that both >TYPE PASSWORD and >TYPE "PASSWORD" work)
Now a DoType routine that checks against password "swordfish":
[code]
array typing[10] ! allow 9 letter password
routine DoType
{
local len
"You type \"";
if parse$ ~= -16 ! -16 seems to be the default value
print parse$;
else
print word[2];
"\" on the computer. A box pops up that says, \"";
len = string(typing,parse$,9) ! write parse$ to array
if not StringDictCompare(typing,"swordfish") or word[2] = "swordfish" ! returns 0 if no difference
"CORRECT!\""
else
"WRONG!\""
return true
}
[/code]
Still, we want the game to accept any wrong word when typing passwords, yet we keep on running into that damn, "I don't know the word 'blah'" response. To get around that, we'll put something into NewParseError:
[code]
replace NewParseError(errornumber,obj)
{
select errornumber
case 1 : {
if word[1] = "type"
{
DoType
main ! fake a turn
return true
}
return false
}
case else : return false
return true
}
[/code]
The downside to this workaround is that we have to fake a turn passing, so if the player tries to UNDO, they'll actually UNDO the [i]previous[/i] turn. All in all, string input in Hugo is definitely something I'd like to see improved so we wouldn't have to resort to this.
Ok, so that's all that. Now, as far as [i]your[/i] particular situation goes, changing the StringDictCompare line to:
[code]
if StringCompare(typing, random_password_string_array) = 0
[/code]
... should work.
Of course, your question was specifically about printing, which makes me think that at least one of the string arrays was filled incorrectly. Hopefully, some of the grammar stuff above helps with that. Otherwise, maybe post some sample code and we can take a look at it.
EDIT: missed a 'return false' in the NewParseErrors routine above.