With the way that the text currently works in D:OS, it's nearly impossible to output the value of a String variable if you don't already know what is supposed to be in it.


If my character's name was Rhidian and stored within the variable STRING_name, then the following code:

Code
CharacterDisplayText(CHARACTER_Player1, _name);


...would look up "Rhidian" in the TranslatedStringKeys, and output the value listed there. If "Rhidian" isn't a Key in the table, then nothing happens. There's no real way to output information we don't already know.



Which leads to my current WIP workaround, with the aim of allowing developers to output the value of an unknown variable. Now, I'm practically inactive in terms of creating an actual mod, but I'm wanting to throw out this idea to see if it sounds reasonable.

Here's some (untested) Story code:

Code
INIT Section
DB_SingleLetter("A", 1);
DB_SingleLetter("B", 2);
DB_SingleLetter("C", 3);
DB_SingleLetter("D", 4);
DB_SingleLetter("E", 5);
DB_SingleLetter("F", 6);
DB_SingleLetter("G", 7);
DB_SingleLetter("H", 8);
DB_SingleLetter("I", 9);
DB_SingleLetter("J", 10);
DB_SingleLetter("K", 11);
DB_SingleLetter("L", 12);
DB_SingleLetter("M", 13);
DB_SingleLetter("N", 14);
DB_SingleLetter("O", 15);
DB_SingleLetter("P", 16);
DB_SingleLetter("Q", 17);
DB_SingleLetter("R", 18);
DB_SingleLetter("S", 19);
DB_SingleLetter("T", 20);
DB_SingleLetter("U", 21);
DB_SingleLetter("V", 22);
DB_SingleLetter("W", 23);
DB_SingleLetter("X", 24);
DB_SingleLetter("Y", 25);
DB_SingleLetter("Z", 26);



KB Section
//Function to be used elsewhere
PROC
PrintText(STRING_word)
THEN
DB_Forward(1);
DB_Backward(1);
CharacterSetVarString(CHARACTER_Player1, "DebugWord", "");
CharacterSetVarInteger(CHARACTER_Player1, "DebugLetterListIndex", 1);
Proc_FindFrequency(_word, 1);
Proc_GrowForward();
Proc_GrowBackward();




-----
//Find which letters the word contains, and then add to a temp database list

PROC
Proc_FindFrequency(STRING_word, INTEGER_index)
AND
DB_SingleLetter(_char, _index)
AND
IntegerSum(_index, 1, _nextIndex)
THEN
Proc_FindLetter(_word, _char);
Proc_FindFrequency(_word, _nextIndex);

PROC
Proc_FindLetter(STRING_word, STRING_char)
AND
StringContains(_word, _char, _output)
AND
_output > 0
THEN
Proc_AddToLetterList(_char);

PROC
Proc_AddToLetterList(STRING_char)
AND
CharacterGetVarInteger(CHARACTER_Player1, "DebugLetterListIndex", _index)
AND
IntegerSum(_index, 1, _nextIndex)
THEN
DB_TempLetterList(_char, _index);
CharacterSetVarInteger(CHARACTER_Player1, "DebugLetterListIndex", _nextIndex);


-------
//Concatenate letters with a growing word (going forward) and see if the word contains it.


PROC
Proc_GrowForward()
AND
DB_Forward(1)
THEN
NOT DB_Forward(1);
Proc_TestNextLetterForward(1);
Proc_GrowForward();


PROC
Proc_TestNextLetterForward(STRING_Word, INTEGER_index)
AND
NOT DB_Forward(1)
AND
IntegerSum(_index, 1, _nextIndex)
AND
CharacterGetVarString(CHARACTER_Player1, "DebugWord", _currentWord)
AND
DB_TempLetterList(_char, _index)
AND
StringConcatenate(_currentWord, _char, _testWord)
AND
StringContains(_Word, _testWord, _result)
AND
_result > 0
THEN
CharacterSetVarString(CHARACTER_Player1, "DebugWord", _testWord);
Proc_OutputLetter(_char, 1);
DB_Forward(1);

PROC
Proc_TestNextLetterForward(STRING_Word, INTEGER_index)
AND
IntegerSum(_index, 1, _nextIndex)
AND
DB_TempLetterList(_char, _index)
THEN
Proc_TestNextLetterForward(_Word, _nextIndex);



PROC
Proc_GrowBackward()
AND
DB_Backward(1)
THEN
NOT DB_Backward(1);
Proc_TestNextLetterBackward(1);
Proc_GrowBackward();


PROC
Proc_TestNextLetterBackward(STRING_Word, INTEGER_index)
AND
NOT DB_Forward(1)
AND
IntegerSum(_index, 1, _nextIndex)
AND
CharacterGetVarString(CHARACTER_Player1, "DebugWord", _currentWord)
AND
DB_TempLetterList(_char, _index)
AND
StringConcatenate(_char, _currentWord, _testWord)
AND
StringContains(_Word, _testWord, _result)
AND
_result > 0
THEN
CharacterSetVarString(CHARACTER_Player1, "DebugWord", _testWord);
Proc_OutputLetter(_char, 0);
DB_Backward(1);

PROC
Proc_TestNextLetterBackward(STRING_Word, INTEGER_index)
AND
IntegerSum(_index, 1, _nextIndex)
AND
DB_TempLetterList(_char, _index)
THEN
Proc_TestNextLetterBackward(_Word, _nextIndex);



------
PROC
Proc_OutputLetter(STRING_char, INTEGER_dir)
AND
_dir > 0
THEN
CharacterDisplayText(CHARACTER_Player1, _char);


PROC
Proc_OutputLetter(STRING_char, INTEGER_dir)
AND
_dir < 1
THEN
CharacterDisplayText(CHARACTER_Player1, _char);



The idea is fairly simple.
1. Have a Key:Content list in the TranslatedString Keys comprised of the individual letters of the alphabet. IE Key: A, Content: A, etc etc.

2. Find out which letters the word contains and store them in a temp database.

3. Starting with a blank string, continue testing letters by concatenating them and seeing if the actual word contains the result.

4. Repeat #3, but with concatenating in the other direction

5. Output result

Now the code posted above doesn't clean itself up (yet) and probably outputs in an incorrect manner, but the gist of it should be usable (or not, since it's untested).

Consider this:

Say I'm wanting to output my name, "Rhidian", that is located in a String.

First I see what letters are present using StringContains-
Code
A
D
I
H
N
R


Then starting with a blank string, I start concatenating them:
Code
"" + "A" = "A"; Contains? Yes


Code
"A" + "A" = "AA"; Contains? No
"AD" No
"AI" No
"AH" No
"AN" Yes


Code
"AN" + everything; No, so start going backwards

"A" + "AN" = "AAN"; Contains? No
"DAN" No
"IAN" Yes


Code
"AIAN" No
"DIAN" Yes


Etc Etc, until it reconstructs "RHIDIAN".