I'm working on implementing an interactive dialog system for talking to NPCs where the player types single word responses (in their native language), which in turn trigger additional dialog with that NPC. So basically, given a value from an entry in strings.dat (text the player types in), I need to find the associated strings.dat key for that value. And I know that the strings.dat key begins with "topic.(NPC_name)." -- I just need to find out what the last part of the key is.
Then I have a script to associate the strings.dat key with a dialogs.dat id. It's actually a bit more complicated than that since one strings.dat key can be linked with multiple dialogs.dat ids, and depending on the current state of the game, the script chooses which one of those dialogs it's going to display.
But since I've been working on the problem some more, I think I've come up with a better solution by doing things in the reverse order that I was originally envisioning, and doing things that way doesn't require parsing the strings.dat file.
In case you aren't following all that, here is an example:
> hello
"Hello, my name is Greg. I'd stay and chat, but I'm busy looking for my hat."
> hat
"My hat was a gift from my wife. I lost it when a gust of wind blew it off my head
as I was exiting the church. I know it is around here somewhere..."
> wife
"My wife Sally runs the inn where you can get a bed to rest for the night."
> inn
"The inn is located at the northwest corner of the town, just past the blacksmith."
The english strings.dat file would contain:
text{ key = "topic.Greg.hello", value = "hello" }
text{ key = "topic.Greg.hat", value = "hat" }
text{ key = "topic.Greg.wife", value = "wife" }
text{ key = "topic.Greg.inn", value = "inn" }
The english dialogs.dat file would contain:
dialog{ id="Greg.greeting", text = "\nHello, my name is Greg. I'd stay and chat, but I'm busy looking for my @hat.\n"}
dialog{ id="Greg.hat_lost", text = "\nMy hat was a gift from my @wife. I lost it when a gust of wind blew it off my head\nas I was exiting the @church. I know it is around here somewhere...\n"}
dialog{ id="Greg.hat_found", text = "\nThank you for finding my hat!\n"}
dialog{ id="Greg.wife", text = "\nMy wife Sally runs the @inn where you can get a bed to rest for the night.\n"}
dialog{ id="Greg.inn_directions", text = "\nThe inn is located at the northwest corner of the town, just past the blacksmith.\n"}
A custom script would then link the string key "topic.Greg.hello" with the dialog id "Greg.greeting"