Author Topic: Complete Text - Alpha  (Read 1152 times)

Last night I decided to figure out what Clockturn's nmhcomplete.cs really did (it is included in his Advanced Client Chat add-on on RTB). After figuring this out I was determined to make it work with something, and after many hours of work, it does.

If you don't know what it does:
Quote from: nmhcomplete.cs
Code: [Select]
// Appends a grey 'suggestion' to the chat box.
// When the user types, if it matches the suggestion it will type along with it.
// If they backspace, it removes the suggestion.
// If they press enter, it inserts the suggestion as actual text.

Right now I have it working simply with giving suggestions of names of players on the server.. When you join a server and your player is made (more specifically when playGUI is woken up), it takes the player list and adds it to a list of words it can use. It only supports 1 word names, though it will attempt to do others. It also has a lot of debug spam.

I also fixed part of nmhcomplete.cs so that when you start typing another letter you don't have to retype it (unless you messed with it before you won't understand this).

I would love to see this get farther than what I got to with the help of the community so I am releasing my version here. If you do make some code for this or fix my bugs, please let me know.

Download: https://dl.dropbox.com/u/6761691/ShareX/2012-07/Client_CompleteText.zip


If you are still having problems understanding what it does maybe this will help: http://i.imgur.com/bOl42.png
« Last Edit: July 27, 2012, 12:49:34 PM by Munkey »

Code: [Select]
function comText_findProgress(%word, %con)
{
%len = strLen(%word);
echo("ComText:: Debug:: %len = " @ %len);
%q = 0;
while(%q < %len)
{
%q += 1;
%progress = getSubStr(%word, 0, %q);
echo("ComTest:: Debug:: %progress = " @ %progress @ "  || & %q = " @ %q);
if(%progress $= %con)
{
echo("ComTest:: Debug:: went through for for if!");
return 1;
break;
}
}
return 0;
}

function comText_getProgress(%word, %con, %this)
{
%len = strLen(%word);
echo("ComText:: Debug:: GP %len = " @ %len);
%q = 0;
while(%q < %len)
{
%q += 1;
%progress = getSubStr(%word, 0, %q);
echo("ComTest:: Debug:: GP %progress = " @ %progress @ "  || & %q = " @ %q);
if(%progress $= %con)
{
echo("ComTest:: Debug:: GP went through for for if!");
%this.comText_lastWord = %word;
return %progress;
break;
}
}
return 0;
}



package completeText
{
function NMH_Type::type(%this)
{
Parent::type(%this);
if(!%this.comText_Check)
{
%con = %this.getValue();
echo("ComText:: Debug:: %con = " @ %con);
%list = $Pref::ComText::Words;
echo("ComText:: Debug:: %list = " @ %list);
%count = getWordCount(%list);
echo("ComText:: Debug:: %count = " @ %count);
%count2 = getWordCount(%con);
echo("ComText:: Debug:: %count2 = " @ %count2);
%con2 = getWord(%con,%count2-1);
echo("ComText:: Debug:: %con2 = " @ %con2);
for(%i = 0; %i < %count; %i++)
{
%word = getWord(%list,%i);
echo("ComText:: Debug:: %word = " @ %word);
echo("ComText:: Debug:: %lastWord = " @ %this.comText_lastWord);
if(comText_findProgress(%word, %con2))
{
if(%this.comText_lastWord $= %word)
{
//nothing
}
else
{
%pro = comText_getProgress(%word, %con2, %this);
%word2 = strReplace(%word,%pro,"");
echo("ComText:: Debug:: %word2 = " @ %word2);
NMH_Type.setcompletionText(%word2);
%this.comText_check = 1;
break;
}
}
}
//if(hasItemOnList(%this,%word))
//{
// NMH_Type.setcompletionText(%word);
//}
}
}

might want to get rid of those debug messages

Code: [Select]
function newChatHud_addLine(%text)
{
Parent::newChatHud_addLine(%text);
%nameToGreet = strReplace(%text," connected.","");
if(%nameToGreet !$= %text)
{
comText_RegisterWord(%nameToGreet);
}
}

sdfsddfsd

secureClientCmd_clientJoin

So it basicly highlights text of names of players as you type it as a suggestion? Cool

Every so often I find myself somehow highlighting text I type, and I can't figure out how.

This is extremely impractical.

If there are these other players:

  • Apollo
  • Axolotl


And I type "A," it suggests "Apollo". If I press "x" because I want to type "Axolotl," it removes the suggestion but doesn't add the x. I have to double-tap it.