First off, if you're not familiar with ASCII, each letter has its own numerical value. You can see them in this chart:
String manipulation in Hugo is mainly a matter of checking for these values and changing them to what you want.
For my "rot13" code to work, the game would have to use a "string" grammar token (the one where the string has to be provided in quoted text, like >WRITE "KILROY WAS HERE" ON ELEVATOR WALL)- something I've found is very hard to train the player to do, but, oh well, this post isn't about how to teach players to use quotation marks where we want them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
routine DoHint | |
{ | |
local x | |
! write parse$ to an array so we can go through it letter by letter | |
x = string(_temp_string,parse$) | |
x = 0 | |
while _temp_string[x] ~= 0 | |
{ | |
! First we'll check if it's a capital letter | |
if _temp_string[x] > 64 and _temp_string[x] < 91 | |
{ | |
! if the letter is before N, we add 13 | |
if _temp_string[x] < 78 | |
_temp_string[x] += 13 | |
else | |
! otherwise we subtract 13 | |
_temp_string[x] -= 13 | |
} | |
! And then we'll check against lowercase letters | |
elseif _temp_string[x] > 96 and _temp_string[x] < 123 | |
{ | |
if _temp_string[x] < 110 | |
_temp_string[x] += 13 | |
else | |
_temp_string[x] -= 13 | |
} | |
x++ | |
} | |
StringPrint(_temp_string) | |
"" | |
} |
EDIT: Ok, I was wrong about the one-letter-off thing, too, even though I guess some of the official hint books were like that. This actually the Magnetic Scrolls code I remembered:
Of course, I'd have to find out how it worked before I could decide whether I could replicate it in Hugo!
No comments:
Post a Comment