Here is the script:
Spoiler
Scriptname HWF_NameScript extends Quest{Full credit for this script goes to TaichiKid from his "Spell Crafting for Skyrim" mod available on the nexus}import Utilityimport StringUtilimport InputHWF_MaintenanceScript Property Maintenance AutoGlobalVariable Property _tck_EnterMode AutoGlobalVariable Property _tck_NoNameEntryMessage AutoMessage Property _tck_TextInputMessageMenu AutoMessage Property _tck_ChooseNameMenu AutoMessage Property _tck_AcceptNameMenu AutoString[] asInputStringValueint aiInputStringCursorActorBase Property wolfPuppy AutoActorBase Property wolfTeen AutoActorBase Property wolfadvlt AutoMiscObject Property wolfPelt AutoEvent OnInit() asInputStringValue = http://forums.bethsoft.com/topic/1501140-text-input-is-there-a-better-way/new String[25]EndEventstring Function GetInputString() int i = 0 string asString =" " while i < 25 asString = substring(asString,0,i+1) + asInputStringValue[i] i += 1 endWhile return asStringEndFunctionFunction UpdateInputString(string aiChar) asInputStringValue[aiInputStringCursor] = aiChar aiInputStringCursor += 1EndFunctionFunction BackspaceInputString() if aiInputStringCursor > 0 aiInputStringCursor -= 1 asInputStringValue[aiInputStringCursor] = "" endIfEndFunctionFunction ClearInputString() int i = 0 aiInputStringCursor = 0 while i < 25 asInputStringValue[i] = "" i += 1 endWhileEndFunctionFunction ReadInputString() int aiReply = -1 RegisterForLetterKeys() ClearInputString() if _tck_NoNameEntryMessage.GetValueInt() == 0 aiReply = _tck_TextInputMessageMenu.show() if aiReply == 1 _tck_NoNameEntryMessage.SetValueInt(1) endif endif Wait(0.5) _tck_EnterMode.SetValueInt(1) TapKey(GetMappedKey("Console")) Wait(0.1) while isinmenumode() Wait(0.25) endwhile UnregisterForLetterKeys()EndFunctionEvent OnKeyDown(int aiKeyCode) if _tck_EnterMode.GetValueInt() == 1 if aiKeyCode == 2 UpdateInputString("1") elseif aiKeyCode == 3 UpdateInputString("2") elseif aiKeyCode == 4 UpdateInputString("3") elseif aiKeyCode == 5 UpdateInputString("4") elseif aiKeyCode == 6 UpdateInputString("5") elseif aiKeyCode == 7 UpdateInputString("6") elseif aiKeyCode == 8 UpdateInputString("7") elseif aiKeyCode == 9 UpdateInputString("8") elseif aiKeyCode == 10 UpdateInputString("9") elseif aiKeyCode == 11 UpdateInputString("0") elseif aiKeyCode == 16 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("Q_") ; Q Else UpdateInputString("q_") EndIf elseif aiKeyCode == 17 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("W_") ; W Else UpdateInputString("w_") EndIf elseif aiKeyCode == 18 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("E_") ; E Else UpdateInputString("e_") EndIf elseif aiKeyCode == 19 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("R_") ; R Else UpdateInputString("r_") EndIf elseif aiKeyCode == 20 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("T_") ; T Else UpdateInputString("t_") EndIf elseif aiKeyCode == 21 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("Y_") ; Y Else UpdateInputString("y_") EndIf elseif aiKeyCode == 22 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("U_") ; U Else UpdateInputString("u_") EndIf elseif aiKeyCode == 23 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("I_") ; I Else UpdateInputString("i_") EndIf elseif aiKeyCode == 24 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("O_") ; O Else UpdateInputString("o_") EndIf elseif aiKeyCode == 25 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("P_") ; P Else UpdateInputString("p_") EndIf elseif aiKeyCode == 30 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("A_") ; A Else UpdateInputString("a_") EndIf elseif aiKeyCode == 31 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("S_") ; S Else UpdateInputString("s_") EndIf elseif aiKeyCode == 32 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("D_") ; D Else UpdateInputString("d_") EndIf elseif aiKeyCode == 33 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("F_") ; F Else UpdateInputString("f_") EndIf elseif aiKeyCode == 34 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("G_") ; G Else UpdateInputString("g_") EndIf elseif aiKeyCode == 35 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("H_") ; H Else UpdateInputString("h_") EndIf elseif aiKeyCode == 36 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("J_") ; J Else UpdateInputString("j_") EndIf elseif aiKeyCode == 37 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("K_") ; K Else UpdateInputString("k_") EndIf elseif aiKeyCode == 38 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("L_") ; L Else UpdateInputString("l_") EndIf elseif aiKeyCode == 44 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("Z_") ; Z Else UpdateInputString("z_") EndIf elseif aiKeyCode == 45 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("X_") ; X Else UpdateInputString("x_") EndIf elseif aiKeyCode == 46 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("C_") ; C Else UpdateInputString("c_") EndIf elseif aiKeyCode == 47 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("V_") ; V Else UpdateInputString("v_") EndIf elseif aiKeyCode == 48 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("B_") ; B Else UpdateInputString("b_") EndIf elseif aiKeyCode == 49 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("N_") ; N Else UpdateInputString("n_") EndIf elseif aiKeyCode == 50 If IsKeyPressed(42) == true || IsKeyPressed(54) == true ; L/R shift UpdateInputString("M_") ; M Else UpdateInputString("m_") EndIf elseif aiKeyCode == 57 UpdateInputString(" _") elseif aiKeyCode == 14 BackspaceInputString() elseif aiKeyCode == 28 TapKey(GetMappedKey("Console")) _tck_EnterMode.SetValueInt(0) endif endifendEventFunction RegisterForLetterKeys() RegisterForKey(2) ; 1 RegisterForKey(3) ; 2 RegisterForKey(4) ; 3 RegisterForKey(5) ; 4 RegisterForKey(6) ; 5 RegisterForKey(7) ; 6 RegisterForKey(8) ; 7 RegisterForKey(9) ; 8 RegisterForKey(10) ; 9 RegisterForKey(11) ; 0 RegisterForKey(16) ; q RegisterForKey(17) ; w RegisterForKey(18) ; e RegisterForKey(19) ; r RegisterForKey(20) ; t RegisterForKey(21) ; y RegisterForKey(22) ; u RegisterForKey(23) ; i RegisterForKey(24) ; o RegisterForKey(25) ; p RegisterForKey(30) ; a RegisterForKey(31) ; s RegisterForKey(32) ; d RegisterForKey(33) ; f RegisterForKey(34) ; g RegisterForKey(35) ; h RegisterForKey(36) ; j RegisterForKey(37) ; k RegisterForKey(38) ; l RegisterForKey(44) ; z RegisterForKey(45) ; x RegisterForKey(46) ; c RegisterForKey(47) ; v RegisterForKey(48) ; b RegisterForKey(49) ; n RegisterForKey(50) ; m RegisterForKey(57) ; space RegisterForKey(28) ; enter RegisterForKey(14) ; backspaceEndFunctionFunction UnregisterForLetterKeys() UnregisterForKey(2) ; 1 UnregisterForKey(3) ; 2 UnregisterForKey(4) ; 3 UnregisterForKey(5) ; 4 UnregisterForKey(6) ; 5 UnregisterForKey(7) ; 6 UnregisterForKey(8) ; 7 UnregisterForKey(9) ; 8 UnregisterForKey(10) ; 9 UnregisterForKey(11) ; 0 UnregisterForKey(16) ; q UnregisterForKey(17) ; w UnregisterForKey(18) ; e UnregisterForKey(19) ; r UnregisterForKey(20) ; t UnregisterForKey(21) ; y UnregisterForKey(22) ; u UnregisterForKey(23) ; i UnregisterForKey(24) ; o UnregisterForKey(25) ; p UnregisterForKey(30) ; a UnregisterForKey(31) ; s UnregisterForKey(32) ; d UnregisterForKey(33) ; f UnregisterForKey(34) ; g UnregisterForKey(35) ; h UnregisterForKey(36) ; j UnregisterForKey(37) ; k UnregisterForKey(38) ; l UnregisterForKey(44) ; z UnregisterForKey(45) ; x UnregisterForKey(46) ; c UnregisterForKey(47) ; v UnregisterForKey(48) ; b UnregisterForKey(49) ; n UnregisterForKey(50) ; m UnregisterForKey(57) ; space UnregisterForKey(28) ; enter UnregisterForKey(14) ; backspaceEndFunctionFunction NameWolf() bool abContinue = true int aiSelection = _tck_ChooseNameMenu.show() if aiSelection == 0 while abContinue ReadInputString() Debug.MessageBox("Name entered:\n" + GetInputString()) aiSelection = _tck_AcceptNameMenu.show() if aiSelection == 0 abContinue = False endif Utility.wait(1.0) endwhile string asName if GetInputString() != " " asName = GetInputString() else asName = "Wolf" endif Maintenance.sName = asName wolfPuppy.SetName(asName) wolfTeen.SetName(asName) wolfadvlt.SetName(asName) wolfPelt.SetName(asName + "'S PELT") ClearInputString() endifEndFunction
The whole thing is set off by the NameWolf() function at the bottom. When this function is called a message is displayed asking the player if they wish to name. When "yes" is clicked, every key gets registered for, the console gets brought up so the player can see what they are typing, while the OnKeyDown() event relays the keys to my script which is keeping track of the string. Once "enter" gets pressed, the console is closed, all keys get unregistered and the player is asked to confirm the inputted name. If "no" the the process is restarted, but if "Yes" then the tracked string gets applied to the wolf.
There are a couple of problems, one being that the name comes out as all capital letters, even though the code should detect a combination of shift+letter. But I hope this will be omitted by using the new SetDisplayName() function directly on the wolf ActorREF.
Like I said, it works ok-ish. I just think there may be a better way...
- Hypno