irswat Posted November 11, 2016 Share Posted November 11, 2016 The contents of a text file is read into a string. The string is parsed word by word into a string array.I search the string array starting at index 0 for a command. Command is found. I search for the end command "Quick" and store this in cmdEnd. For example: "Equip Staff of Magus QUICK" In this case cmdEnd=4. The script does stuff to figure out what the command is, etc. Then it loops to the next "line" of the string array. Now I search the string array starting at index cmdEnd for Equip, or starting at index 4 in other words. The word Equip is definitely in index 5 of the string array. Everything is exactly as it should be. For some reason the array command Find is not working. It's like it works once and then breaks. Any ideas?Below is the entire source code. Here is the zip. extract to skyrim folder.When testing make sure tracelog is enabled.The code is a bit of a mess, please pardon that. I need to break some of this down into functions, but I got lazy. Nevertheless the relevant code is directly below the line debug.trace("SVE Dump Complete.") The script finishes running in like .000017 seconds so you can basically load a clean save, wait a second for the message saying the dumps are complete, and then close. Then open up the tracelog papyrus0.You're looking for Loop 2 out of 3, FindCommandCounter=1 ("Equip"). "Equip" is definitely at SVE_DumpArray[5], but when I search for equip starting at 4 "Equip" is not being detected in the array. Scriptname SVE_ParserEngine extends quest Import StringUtil FormList Property ShoutFormList Auto FormList Property SpellFormList Auto FormList Property CommandFormList Auto FormList Property ArmorFormList Auto FormList Property ArrowFormList Auto FormList Property WeaponFormList Auto FormList Property SummonFormList Auto Actor Property PlayerRef Auto Actor Property TargetRef Auto Event OnInit() Main() endEvent function Main() StartTime = Utility.GetCurrentGameTime() ;declarations string CurrentDump string CurrentLine string CurrentWord string CurrentCMD string MaterialType string WeaponType string ArmorType string WeaponName string ArmorName string ItemFound string iToParse=0 ;need to rename this int DumpLineCount=0 int LoopCounter=1 int CurrentWordIndex int WordsOnCurrentLine=0 int CurrentDumpWordIndex=0 int FindCommandCounter=0 int iCMDFound=0 int endCMD=0 int CMDParserCounter=0 int CMDLength=0 int iItemFound=0 int iCurrentSearchStart=0 bool ItemNotFound=false bool CommandFound=false bool break=false float StartTime float EndTime ;implement "mic" button debug.trace("Initializing SVE_DumpArray") string[] SVE_DumpArray=new string[100] string[] CommandList=new string[10] ;list of commands int[] fCommandList=new int[10] ;this will keep track of the frequencies of usage CommandList[0]="Thuum" CommandList[1]="Equip" CommandList[2]="Unequip" Commandlist[3]="Use" CommandList[4]="Cast" CommandList[5]="Map" CommandList[6]="Save" CommandList[7]="Exit" string[] MaterialList=new string[20] ;list of materials MaterialList[0]="Iron" MaterialList[1]="Steel" MaterialList[2]="Dwarven" MaterialList[3]="Dragonbone" MaterialList[4]="Ebony" MaterialList[5]="Chitin" MaterialList[6]="Glass" MaterialList[7]="Gold" MaterialList[8]="Silver" MaterialList[9]="Dwemer" string[] WeaponTypes=new string[20] ;list of weapon types WeaponTypes[0]="Sword" WeaponTypes[1]="Dagger" WeaponTypes[2]="Bow" WeaponTypes[3]="Staff" WeaponTypes[4]="Greatsword" WeaponTypes[5]="Crossbow" WeaponTypes[6]="Blade" WeaponTypes[7]="Mace" WeaponTypes[8]="Warhammer" WeaponTypes[9]="Battleaxe" string[] ArmorTypes=new string[10] ;list of places armor can be equipped ArmorTypes[0]="Helmet" ArmorTypes[1]="Breastplate" ArmorTypes[2]="Boots" ArmorTypes[3]="Gauntlets" ArmorTypes[4]="Shield" ArmorTypes[5]="Armor" string[] ArmorNames=new String[100] ;list of unique phrases associated with specific armors ArmorNames[0]="Hardening" string[] WeaponNames=new String[100] ;list of unique phrases associated with specific weapons WeaponNames[0]="Woe" WeaponNames[1]="Nightingale" WeaponNames[2]="Miraak" WeaponNames[3]="Magus" string[] EquipSlots=new string[20] ;list of places armor can be equipped string[] Formulator=new String[10] CurrentDump=Dump_PO() ;debug.trace("Printing SVE_PO" + CurrentDump) DumpLineCount=GetNumLines(CurrentDump) ;debug.trace("SVE_PO number of lines: " + DumpLineCount) ;fills string array with DUMP while (LoopCounter<=DumpLineCount) CurrentLine=GetLine(CurrentDump, LoopCounter, DumpLineCount) ;debug.trace("Current Line: " + CurrentLine) WordsOnCurrentLine=GetNumWords(CurrentLine) ;debug.trace("Number of words on current line: " + WordsOnCurrentLine) CurrentWordIndex=1 while (CurrentWordIndex<=WordsOnCurrentLine) ; ;Get word y on line x CurrentWord=GetWord(CurrentLine, WordsOnCurrentLine, CurrentWordIndex) ;debug.trace("Word " + CurrentDumpWordIndex + ": " + CurrentWord) ;store word y in array SVE_DumpArray[CurrentDumpWordIndex]=CurrentWord debug.trace("Word " + CurrentDumpWordIndex + ": " + SVE_DumpArray[CurrentDumpWordIndex]) CurrentWordIndex+=1 CurrentDumpWordIndex+=1 endWhile debug.trace("Line " + LoopCounter + " complete") LoopCounter=LoopCounter+1 endWhile LoopCounter=1 CMDLength=0 debug.notification("SVE DUMP COMPLETE.") while (LoopCounter<=DumpLineCount) debug.trace("Loop " + LoopCounter + " of " + DumpLineCount) debug.trace("FindCommandCounter Reset? " + FindCommandCounter) while (FindCommandCounter<=7) ;7 commands for now currentCMD=CommandList[FindCommandCounter] debug.trace("Searching for command " + CommandList[FindCommandCounter] + " beginning in SVE_Dump at index " + iCurrentSearchStart) iCMDFound=SVE_DumpArray.Find(currentCMD, iCurrentSearchStart) debug.trace("FindCommandCounter: " + FindCommandCounter) debug.trace("Searching SVE Dump for executable") if (iCMDFound>=0) ;this cycles through the command form list (e.g. equip, use, cast, thuum, etc) CurrentCMD=SVE_DumpArray[iCMDFound] debug.trace("Command found: " + SVE_DumpArray[iCMDFound] + " in index " + iCMDFound) CommandFound=true else CommandFound=false endif if CommandFound==true if CurrentCMD=="Thuum" ;search next three indices for thuum words against Thuum formlist ;do all three words belong to the same thuum? ;how many words does the player know? ;shout elseif CurrentCMD=="Equip" debug.trace("Equip CMD detected") endCMD=SVE_DumpArray.Find("QUICK", iCMDFound) CMDLength=endCMD-iCMDFound while (CMDParserCounter<=CMDLength) break=false iToParse=SVE_DumpArray[iCMDFound + CMDParserCounter] iItemFound=MaterialList.Find(iToParse) if ((iItemFound>=0) && (break==false)) MaterialType=SVE_DumpArray[iCMDFound + CMDParserCounter] break=true debug.trace("Material type detected in index " + CMDParserCounter) elseif iItemFound<0 iItemFound=WeaponTypes.Find(iToParse) endif if ((iItemFound>=0) && (break==false)) WeaponType=SVE_DumpArray[iCMDFound + CMDParserCounter] debug.trace("Weapon type detected in index " + CMDParserCounter) break=true elseif iItemFound<0 iItemFound=ArmorTypes.Find(iToParse) endif if ((iItemFound>=0) && (break==false)) ArmorType=SVE_DumpArray[iCMDFound + CMDParserCounter] debug.trace("Armor type detected in index " + CMDParserCounter) break=true elseif iItemFound<0 iItemFound=WeaponNames.Find(iToParse) endif if ((iItemFound>=0) && (break==false)) WeaponName=SVE_DumpArray[iCMDFound + CMDParserCounter] debug.trace("Unique weapon modifier detected in index " + CMDParserCounter) break=true elseif iItemFound<0 iItemFound=ArmorNames.Find(iToParse) endif if ((iItemFound>=0) && (break==false)) ArmorName=SVE_DumpArray[iCMDFound + CMDParserCounter] debug.trace("Unique armor modifier detected in index " + CMDParserCounter) break=true else ItemNotFound==true endif CMDParserCounter+=1 endWhile if MaterialType Formulator[0]=MaterialType endif if WeaponType Formulator[1]=WeaponType endif if ArmorType Formulator[2]=ArmorType endif if WeaponName Formulator[3]=WeaponName endif if ArmorName Formulator[4]=ArmorName endif Formulator[5]=Formulator[0]+" "+Formulator[1]+" "+Formulator[2]+" "+Formulator[3]+" "+Formulator[4] debug.trace(Formulator[5]) ;weapon or armor? ;armor/clothing ;should look for keywords like armor, breastplate, helmet, boots, gauntlets, cloaks, etc. ;this will be called piece ;modifier type will be called piecetype, this will be mostly materials ;expecting form "equip ebony armor", "equip dragonbone helmet", etc ;weapon ;name (staff of magus) ;material ;type (e.g. dagger, sword, greatsword, staff, bow, gloves) ;equipping hand ;expecting form "ebony bow and arrows", "or ebony bow and ebony arrows" ;expecting form "equip dragonsting dagger in left hand" ;expecting form "equip staff of magus in right hand", etc. elseif CurrentCMD=="Unequip" elseif CurrentCMD=="Use" ;potion formlist elseif CurrentCMD=="Cast" ;spell formlist elseif CurrentCMD=="Map" ;int MapKey = Input.GetMappedKey("Quick Map",0x00) ;Input.TapKey(MapKey) elseif CurrentCMD=="Save" ;int SaveKey = Input.GetMappedKey("Quicksave",0x00) ;Input.TapKey(SaveKey) ;debug.trace("save") elseif CurrentCMD=="Exit" ;Debug.QuitGame() endif endif ;end command found==true FindCommandCounter+=1 endWhile debug.trace("Reinitializing variables") MaterialType="" WeaponType="" ArmorType="" WeaponName="" ArmorName="" Formulator[0]="" Formulator[1]="" Formulator[2]="" Formulator[3]="" Formulator[4]="" Formulator[5]="" CMDParserCounter=0 LoopCounter+=1 iCurrentSearchStart=endCMD FindCommandCounter=0 CommandFound=false endWhile EndTime = Utility.GetCurrentGameTime() float PerfTest=EndTime-StartTime debug.notification("Command parser test complete in " + PerfTest + " seconds.") DEBUG.Notification("Dumping SVE_Dump to Log") int x=0 while x<=13 debug.trace("word " + x + " " + SVE_DumpArray[x]) x+=1 endwhile endfunction string function Dump_PO() ;shoutout to MinionMaster for helping me understand the syntax and Find the right functions in MiscUtil.psc ;this function is his work string SVE_PO string sDatafileName = "data/SVE_PI.txt" int LineCountParserIndex=0 int EndOfFileFound=0 debug.trace("dumping from " + sDatafileName + "to SVE_PO") if MiscUtil.FileExists(sDatafileName) debug.trace("File found: reading file.") SVE_PO = MiscUtil.ReadFromFile (sDatafileName) ;EndOfFileFound=Find(SVE_PO, "/delete", LineCountParserIndex) ;if EndOfFileFound==-1 ; MiscUtil.WriteToFile(sDatafileName, "/delete", true, false) ;endif endif return SVE_PO endfunction int function GetNumLines(string SVE_PO) ;Find out how many distinct lines are in the string int LineCountStartIndex=0 int NullCharIndex=0 int LineCount=0 ; int SVE_PO_End=-1 while (NullCharIndex!=-1) ;delete not found on this line NullCharIndex=Find(SVE_PO, "/n", LineCountStartIndex) ;end of line ; if NullCharIndex==-1 ; SVE_PO_End=Find(SVE_PO,"/delete",LineCountStartIndex) ;end of dump file ; endif LineCount=LineCount+1 LineCountStartIndex=NullCharIndex+2 NullCharIndex=Find(SVE_PO, "/n", LineCountStartIndex) ;to prevent an extra line being added endWhile return LineCount endFunction string function GetLine(string SVE_PO,int CurrentLineNumber,int NumberOfLines) int NullCharIndex=0 int LineStartIndex=0 int EndDumpIndex=0 int LinesToSkip=CurrentLineNumber - 1 int LinesSkipped=0 string LineReturn while (LinesSkipped<=LinesToSkip) NullCharIndex=Find(SVE_PO, "/n", LineStartIndex) if (NullCharIndex != -1) LineReturn=Substring(SVE_PO, LineStartIndex, (NullCharIndex - LineStartIndex)) LineStartIndex=NullCharIndex+2 LinesSkipped+=1 endif endWhile return LineReturn endFunction int function GetNumWords(string SVE_CurrentLine) int WordBeginningIndex=0 ;beginning of the word index int SpaceIndex=0 ;end of the word index int WordCount=0 ;number of words on a line int NullCharIndex=0 int EndDumpIndex NullCharIndex=Find(SVE_CurrentLine, "/n", WordBeginningIndex) ;Finds index of null character/end of line while (SpaceIndex!=-1) ;while there are spaces there are words left SpaceIndex=Find(SVE_CurrentLine, " ", WordBeginningIndex) WordCount+=1 WordBeginningIndex=SpaceIndex+1 ;space + 1 endWhile return WordCount endFunction string function GetWord(string SVE_CurrentLine, int WordsOnLine, int WordNumber) int EndOfWord=0 int NullCharIndex=0 int WordParserStart=0 int WordsSkipped=0 int WordsToSkip=WordNumber - 1 ;this is incorrect e.g. on the first pass wordsonline==8, and wordnumber==1, but will skip 7 words. int WordLength=0 bool EndOfLine=false string WordReturn ;parse distinct words from first line [x]-' '\ ;for x=1;x<=WordCount;x++ While (WordsSkipped<=WordsToSkip) EndOfWord=Find(SVE_CurrentLine," ", WordParserStart) ;accounting for space ;Debug.trace("End of Word[i]: " + EndOfWord + "NullCharIndex[i]: " + NullCharIndex) WordLength=EndOfWord - WordParserStart WordReturn=Substring(SVE_CurrentLine, WordParserStart, WordLength) WordParserStart=EndOfWord+1 WordsSkipped+=1 endWhile return WordReturn endFunction much thanks and shout outs to whoever helps me figure this out. Link to comment Share on other sites More sharing options...
irswat Posted November 11, 2016 Author Share Posted November 11, 2016 (edited) I've run extensive testing on this script. I can not figure out why the script is not detecting the word "Equip" in SVE_DumpArray[5]. Is this an engine bug or what?edit: I've found a clue by copying and pasting the log file into N++. notice word 5 and word 10. Maybe has to do when I getword(). Something to do with a null character? Word 0: Equip [11/11/2016 - 02:30:52PM] Word 1: Staff [11/11/2016 - 02:30:52PM] Word 2: of [11/11/2016 - 02:30:52PM] Word 3: Magus [11/11/2016 - 02:30:52PM] Word 4: QUICK [11/11/2016 - 02:30:52PM] Line 1 complete [11/11/2016 - 02:30:52PM] Word 5: Equip [11/11/2016 - 02:30:52PM] Word 6: Blade [11/11/2016 - 02:30:52PM] Word 7: of [11/11/2016 - 02:30:52PM] Word 8: Woe [11/11/2016 - 02:30:52PM] Word 9: QUICK [11/11/2016 - 02:30:52PM] Line 2 complete [11/11/2016 - 02:30:52PM] Word 10: Equip [11/11/2016 - 02:30:52PM] Word 11: Nightingale [11/11/2016 - 02:30:52PM] Word 12: Bow [11/11/2016 - 02:30:52PM] Word 13: QUICK [11/11/2016 - 02:30:52PM] Line 3 complete [11/11/2016 - 02:30:52PM] Loop 1 of 3 [11/11/2016 - 02:30:52PM] FindCommandCounter Reset? 0 [11/11/2016 - 02:30:52PM] Searching for command Thuum beginning in SVE_Dump at index 0 [11/11/2016 - 02:30:52PM] iCMDFound: -1 [11/11/2016 - 02:30:52PM] Searching for command Equip beginning in SVE_Dump at index 0 [11/11/2016 - 02:30:52PM] iCMDFound: 0 [11/11/2016 - 02:30:52PM] Command found: Equip in index 0 [11/11/2016 - 02:30:52PM] Equip CMD detected [11/11/2016 - 02:30:52PM] Weapon type detected in index 1 [11/11/2016 - 02:30:52PM] Unique weapon modifier detected in index 3 [11/11/2016 - 02:30:52PM] Staff Magus [11/11/2016 - 02:30:52PM] Searching for command Unequip beginning in SVE_Dump at index 0 [11/11/2016 - 02:30:52PM] iCMDFound: -1 [11/11/2016 - 02:30:52PM] Searching for command Use beginning in SVE_Dump at index 0 [11/11/2016 - 02:30:52PM] iCMDFound: -1 [11/11/2016 - 02:30:52PM] Searching for command Cast beginning in SVE_Dump at index 0 [11/11/2016 - 02:30:52PM] iCMDFound: -1 [11/11/2016 - 02:30:52PM] Searching for command Map beginning in SVE_Dump at index 0 [11/11/2016 - 02:30:52PM] iCMDFound: -1 [11/11/2016 - 02:30:52PM] Searching for command Save beginning in SVE_Dump at index 0 [11/11/2016 - 02:30:52PM] iCMDFound: -1 [11/11/2016 - 02:30:52PM] Searching for command Exit beginning in SVE_Dump at index 0 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Reinitializing variables [11/11/2016 - 02:30:53PM] Loop 2 of 3 [11/11/2016 - 02:30:53PM] FindCommandCounter Reset? 0 [11/11/2016 - 02:30:53PM] Searching for command Thuum beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Equip beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Unequip beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Use beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Cast beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Map beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Save beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Exit beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Reinitializing variables [11/11/2016 - 02:30:53PM] Loop 3 of 3 [11/11/2016 - 02:30:53PM] FindCommandCounter Reset? 0 [11/11/2016 - 02:30:53PM] Searching for command Thuum beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Equip beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Unequip beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Use beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Cast beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Map beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Save beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Searching for command Exit beginning in SVE_Dump at index 4 [11/11/2016 - 02:30:53PM] iCMDFound: -1 [11/11/2016 - 02:30:53PM] Reinitializing variables [11/11/2016 - 02:30:53PM] Word 0 Equip [11/11/2016 - 02:30:53PM] Word 1 Staff [11/11/2016 - 02:30:53PM] Word 2 of [11/11/2016 - 02:30:53PM] Word 3 Magus [11/11/2016 - 02:30:53PM] Word 4 QUICK [11/11/2016 - 02:30:53PM] Word 5 Equip [11/11/2016 - 02:30:53PM] Word 6 Blade [11/11/2016 - 02:30:53PM] Word 7 of [11/11/2016 - 02:30:53PM] Word 8 Woe [11/11/2016 - 02:30:53PM] Word 9 QUICK [11/11/2016 - 02:30:53PM] Word 10 Equip [11/11/2016 - 02:30:53PM] Word 11 Nightingale [11/11/2016 - 02:30:53PM] Word 12 Bow [11/11/2016 - 02:30:53PM] Word 13 QUICK It looks like a hidden carriage return. not sure how to get rid of it. suggestions? Edited November 11, 2016 by irswat Link to comment Share on other sites More sharing options...
irswat Posted November 11, 2016 Author Share Posted November 11, 2016 problem solved adding +2 to the StartIndex for getting words and ending lines did the trick to avoid the hidden carriage return. awesome! Link to comment Share on other sites More sharing options...
irswat Posted November 11, 2016 Author Share Posted November 11, 2016 [11/11/2016 - 03:44:12PM] Word 0: Equip [11/11/2016 - 03:44:12PM] Word 1: Staff [11/11/2016 - 03:44:12PM] Word 2: of [11/11/2016 - 03:44:12PM] Word 3: Magus [11/11/2016 - 03:44:12PM] Word 4: QUICK [11/11/2016 - 03:44:12PM] Line 1 complete [11/11/2016 - 03:44:12PM] Word 5: Equip [11/11/2016 - 03:44:12PM] Word 6: Blade [11/11/2016 - 03:44:12PM] Word 7: of [11/11/2016 - 03:44:12PM] Word 8: Woe [11/11/2016 - 03:44:12PM] Word 9: QUICK [11/11/2016 - 03:44:12PM] Line 2 complete [11/11/2016 - 03:44:12PM] Word 10: Equip [11/11/2016 - 03:44:12PM] Word 11: Nightingale [11/11/2016 - 03:44:12PM] Word 12: Bow [11/11/2016 - 03:44:12PM] Word 13: QUICK [11/11/2016 - 03:44:12PM] Line 3 complete [11/11/2016 - 03:44:12PM] [DLC2PillarBuilderActorScript < (04018FD0)>]OnPackageStart() [11/11/2016 - 03:44:12PM] [DLC2PillarBuilderActorScript < (04018FCF)>]OnPackageStart() [11/11/2016 - 03:44:12PM] Loop 1 of 3 [11/11/2016 - 03:44:12PM] FindCommandCounter Reset? 0 [11/11/2016 - 03:44:12PM] Searching for command Thuum beginning in SVE_Dump at index 0 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Equip beginning in SVE_Dump at index 0 [11/11/2016 - 03:44:12PM] iCMDFound: 0 [11/11/2016 - 03:44:12PM] Command found: Equip in index 0 [11/11/2016 - 03:44:12PM] Equip CMD detected [11/11/2016 - 03:44:12PM] [DLC2PillarBuilderActorScript < (04018FC3)>]OnPackageStart() [11/11/2016 - 03:44:12PM] [DLC2PillarBuilderActorScript < (040177DD)>]OnPackageStart() [11/11/2016 - 03:44:12PM] [DLC2PillarBuilderActorScript < (04018FA1)>]OnPackageStart() [11/11/2016 - 03:44:12PM] [DLC2PillarBuilderActorScript < (040177DB)>]OnPackageStart() [11/11/2016 - 03:44:12PM] [DLC1_2StateActivatorWithGlobal < (02017D59)>]: SetOpen called with abOpen = False [11/11/2016 - 03:44:12PM] Weapon type detected in index 1 [11/11/2016 - 03:44:12PM] Unique weapon modifier detected in index 3 [11/11/2016 - 03:44:12PM] Staff Magus [11/11/2016 - 03:44:12PM] Searching for command Unequip beginning in SVE_Dump at index 0 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Use beginning in SVE_Dump at index 0 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Cast beginning in SVE_Dump at index 0 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Map beginning in SVE_Dump at index 0 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Save beginning in SVE_Dump at index 0 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Exit beginning in SVE_Dump at index 0 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Reinitializing variables [11/11/2016 - 03:44:12PM] Loop 2 of 3 [11/11/2016 - 03:44:12PM] FindCommandCounter Reset? 0 [11/11/2016 - 03:44:12PM] Searching for command Thuum beginning in SVE_Dump at index 4 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Equip beginning in SVE_Dump at index 4 [11/11/2016 - 03:44:12PM] iCMDFound: 5 [11/11/2016 - 03:44:12PM] Command found: Equip in index 5 [11/11/2016 - 03:44:12PM] Equip CMD detected [11/11/2016 - 03:44:12PM] Weapon type detected in index 1 [11/11/2016 - 03:44:12PM] Unique weapon modifier detected in index 3 [11/11/2016 - 03:44:12PM] Blade Woe [11/11/2016 - 03:44:12PM] Searching for command Unequip beginning in SVE_Dump at index 4 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Use beginning in SVE_Dump at index 4 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Cast beginning in SVE_Dump at index 4 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Map beginning in SVE_Dump at index 4 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Save beginning in SVE_Dump at index 4 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Exit beginning in SVE_Dump at index 4 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Reinitializing variables [11/11/2016 - 03:44:12PM] Loop 3 of 3 [11/11/2016 - 03:44:12PM] FindCommandCounter Reset? 0 [11/11/2016 - 03:44:12PM] Searching for command Thuum beginning in SVE_Dump at index 9 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Equip beginning in SVE_Dump at index 9 [11/11/2016 - 03:44:12PM] iCMDFound: 10 [11/11/2016 - 03:44:12PM] Command found: Equip in index 10 [11/11/2016 - 03:44:12PM] Equip CMD detected [11/11/2016 - 03:44:12PM] Unique weapon modifier detected in index 1 [11/11/2016 - 03:44:12PM] Weapon type detected in index 2 [11/11/2016 - 03:44:12PM] Bow Nightingale [11/11/2016 - 03:44:12PM] Searching for command Unequip beginning in SVE_Dump at index 9 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Use beginning in SVE_Dump at index 9 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Cast beginning in SVE_Dump at index 9 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Map beginning in SVE_Dump at index 9 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Save beginning in SVE_Dump at index 9 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Searching for command Exit beginning in SVE_Dump at index 9 [11/11/2016 - 03:44:12PM] iCMDFound: -1 [11/11/2016 - 03:44:12PM] Reinitializing variables [11/11/2016 - 03:44:12PM] Word 0 Equip [11/11/2016 - 03:44:12PM] Word 1 Staff [11/11/2016 - 03:44:12PM] Word 2 of [11/11/2016 - 03:44:12PM] Word 3 Magus [11/11/2016 - 03:44:12PM] Word 4 QUICK [11/11/2016 - 03:44:12PM] Word 5 Equip [11/11/2016 - 03:44:12PM] Word 6 Blade [11/11/2016 - 03:44:12PM] Word 7 of [11/11/2016 - 03:44:12PM] Word 8 Woe [11/11/2016 - 03:44:12PM] Word 9 QUICK [11/11/2016 - 03:44:12PM] Word 10 Equip [11/11/2016 - 03:44:12PM] Word 11 Nightingale [11/11/2016 - 03:44:12PM] Word 12 Bow [11/11/2016 - 03:44:12PM] Word 13 QUICK Link to comment Share on other sites More sharing options...
irswat Posted November 11, 2016 Author Share Posted November 11, 2016 script parses 3 lines, 15 words in seventeen hundred thousandths of a second! that's really fast! Link to comment Share on other sites More sharing options...
ReDragon2013 Posted November 11, 2016 Share Posted November 11, 2016 I see YOU FOUND the mistake, well done! Do not forget Skyrim is multithreading.First of all you should have more respect if somebody answers to your posting. Each nexus user spends time (spare time) to give you depends on his knowledge a best as possible answer/solution.Your papyrus coding style is horrible. The script (and archive) you provided here is far away to be easy to understand. I tried my best to make it readable.Your archive is missing of "stringUtil.psc" and "miscUtil.psc". The first script I found in SKSE script extender package. About the second I have no idea.Here is the result of my scripting re-work. Read my intern comments carefully! Scriptname SVE_ParserEngine extends Quest {rewritten by ReDragon 2016} ;Import StringUtil ; a bad idea to do that, only for scripting experts useful (ReDragon) FormList PROPERTY fml_Shout auto ; ShoutFormList FormList PROPERTY fml_Spell auto ; SpellFormList FormList PROPERTY fml_Command auto ; CommandFormList FormList PROPERTY fml_Armor auto ; ArmorFormList FormList PROPERTY fml_Arrow auto ; ArrowFormList FormList PROPERTY fml_Weapon auto ; WeaponFormList FormList PROPERTY fml_Summon auto ; SummonFormList ;Actor PROPERTY PlayerRef auto ; UnUSED by now Actor PROPERTY TargetRef auto ; UnUSED !? ;Int[] fCommandList ; UnUSED // keeps track of the frequencies of usage ;String[] EquipSlots ; UnUSED // list of places armor can be equipped ; array string lists String[] s_DA ; SVE_DumpArray String[] s_CMD ; CommandList string[] s_Material ; MaterialList string[] s_Weapon ; WeaponTypes string[] s_Armor ; ArmorTypes string[] sn_Armor ; ArmorNames // list of unique phrases associated with specific armors string[] sn_Weapon ; WeaponNames // list of unique phrases associated with specific weapons string CurrentDump ; text data string holder Int DumpLineCount ; max. text lines of data string ; Debugging only, should be removed on mod release Float StartTime ; -- EVENTs -- 2 EVENT OnInit() RegisterForSingleUpdateGameTime(0.0) ; use only fast code here, otherwise run it asynchronously ENDEVENT EVENT OnUpdateGameTime() ; this is SKYRIM event, FallOut 4 has other event for that myF_Init_Arrays() Main() myF_CleanUp_Arrays() CurrentDump = "" DumpLineCount = 0 ENDEVENT ; -- FUNCTIONs -- 9 ;---------------------------- FUNCTION myF_CleanUp_Arrays() ;---------------------------- string[] b ; empty array to make arrays on top <None> s_DA = b ; SVE_DumpArray s_CMD = b ; CommandList s_Material = b ; MaterialList s_Weapon = b ; WeaponTypes s_Armor = b ; ArmorTypes sn_Armor = b ; ArmorNames sn_Weapon = b ; WeaponNames ENDFUNCTION ;------------------------- FUNCTION myF_Init_Arrays() ;------------------------- ; ####### Debug.Trace("SVE_TEST: Initializing SVE_Arrays") ; ####### s_DA = new String[100] ; space for dump data ; // commands // ;;; fCommandList = new Int[10] ; s_CMD = new String[10] ; list of commands s_CMD[0] = "Thuum" s_CMD[1] = "Equip" s_CMD[2] = "Unequip" s_CMD[3] = "Use" s_CMD[4] = "Cast" s_CMD[5] = "Map" s_CMD[6] = "Save" s_CMD[7] = "Exit" ; // materials // s_Material = new String[20] ; list of predefined materials [10] s_Material[0] = "Iron" ; Eisen s_Material[1] = "Steel" ; Stahl s_Material[2] = "Dwarven" s_Material[3] = "Dragonbone" ; Drachenknochen s_Material[4] = "Ebony" s_Material[5] = "Chitin" s_Material[6] = "Glass" ; Vulkanglas s_Material[7] = "Gold" s_Material[8] = "Silver" ; Silber s_Material[9] = "Dwemer" ; // weapons // s_Weapon = new String[20] ; list of predefined weapon types [10] s_Weapon[0] = "Sword" ; Schwert s_Weapon[1] = "Dagger" ; Dolch s_Weapon[2] = "Bow" ; Bogen s_Weapon[3] = "Staff" ; Zauberstab s_Weapon[4] = "Greatsword" ; Langschwert s_Weapon[5] = "Crossbow" ; Armbrust s_Weapon[6] = "Blade" ; s_Weapon[7] = "Mace" ; Streitkolben s_Weapon[8] = "Warhammer" ; Kriegshammer s_Weapon[9] = "Battleaxe" ; Großaxt ;;; s_Weapon[10]= "Katana" ; // armors // ;;; EquipSlots = new string[20] ; s_Armor = new string[10] ; list of predefined armor types that can be equipped [6] s_Armor[0] = "Helmet" ; Helm s_Armor[1] = "Breastplate" ; Brustpanzer s_Armor[2] = "Boots" ; Schuhe s_Armor[3] = "Gauntlets" ; Handschuhe s_Armor[4] = "Shield" ; Schild s_Armor[5] = "Armor" ; Rüstung ; // unique phrases // sn_Armor = new String[100] ; list of unique phrases associated with specific armors sn_Weapon = new String[100] ; list of unique phrases associated with specific weapons sn_Armor[0] = "Hardening" sn_Weapon[0] = "Woe" sn_Weapon[1] = "Nightingale" sn_Weapon[2] = "Miraak" sn_Weapon[3] = "Magus" ENDFUNCTION ;------------------------------ Int FUNCTION myF_GetDumpLines() ;------------------------------ ;Find out how many distinct lines are in the string ; ******************************************************************************* ; *** I assume string "CurrentDump" has been declared on top as heap variable *** ; ******************************************************************************* int LineCountStartIndex = 0 int LineCount = 0 ; the next loop is a bit strange because of twice Find(), should be carefully optimized (ReDragon 2016) int i = 0 ; i = NullCharIndex WHILE (i != -1) i = StringUtil.Find(CurrentDump, "/n", LineCountStartIndex) ; "/n" is EOLN which means end of line LineCount += 1 LineCountStartIndex = i + 2 i = StringUtil.Find(CurrentDump, "/n", LineCountStartIndex) ; to prevent an extra line being added ENDWHILE RETURN LineCount ENDFUNCTION ;----------------------------- FUNCTION myF_GetDump(String s) ; "s" means stringFileName ;----------------------------- ; shout out to MinionMaster for helping me understand the syntax and ; Find the right functions in "MiscUtil.psc" this function is his work ; ******************************************************************************* ; *** I assume string "CurrentDump" has been declared on top as heap variable *** ; *** I assume int "DumpLineCount" has been declared on top as heap variable *** ; ******************************************************************************* ; ####### Debug.Trace("SVE_TEST: dumping in progress for " +s) ; ####### IF MiscUtil.FileExists(s) ; *** script MiscUtil.psc is unknown *** ELSE Debug.Trace("SVE_TEST -- Error 01 -- file not found!") RETURN ; - STOP - ENDIF ;--------------------- CurrentDump = MiscUtil.ReadFromFile(s) ; READ DUMP DumpLineCount = myF_GetDumpLines() ; GET max lines for current dump ;int LineCountParserIndex = 0 ;int i = StringUtil.Find(CurrentDump, "/delete", LineCountParserIndex) ; i = EndOfFileFound ;IF (i == -1) ;; Debug.Trace("SVE_TEST -- Error 02 -- EOF not found!") ; MiscUtil.WriteToFile(s, "/delete", TRUE, False) ;ENDIF ENDFUNCTION ;-------------- FUNCTION Main() ;-------------- StartTime = Utility.GetCurrentGameTime() ; * START TIMER * ; implement "mic" button ; ~~~~~~~~~~~~~~~~~~~~~~ CurrentDump = myF_GetDump("data/SVE_PI.txt") ; fills string array with DUMP ;; Debug.Trace("SVE_TEST: has " +DumpLineCount+ " lines (" +CurrentDump+ ")") string CurrentLine ;;; string CurrentCMD ; obsolete, instead we use "j" as array command counter int iCurrentSearchEnd = 0 int iCurrentSearchStart = 0 int i = 1 ; i = LoopCounter WHILE (i <= DumpLineCount) CurrentLine = myF_GetLine(i) ; "GetLine(CurrentDump, LoopCounter, DumpLineCount)" int WordsOnCurrentLine = GetNumWords(CurrentLine) ;; Debug.Trace("Number of words on current line: " +WordsOnCurrentLine) int x = 1 ; x = CurrentWordIndex, (x - 1) = CurrentDumpWordIndex WHILE (x <= WordsOnCurrentLine) ; Get word y on line x and store word y in array s_DA[x - 1] = myF_GetWord(CurrentLine, WordsOnCurrentLine, x) ; "GetWord(CurrentLine, WordsOnCurrentLine, CurrentWordIndex)" x = x + 1 ENDWHILE ;; Debug.Trace("SVE_TEST: Line " +i+ " completed!") i = i + 1 ENDWHILE ; ---------------------------------------- Debug.Notification("SVE DUMP COMPLETE.") ; ---------------------------------------- i = 1 WHILE (i <= DumpLineCount) ;; Debug.Trace("Loop " +i+ " of " + DumpLineCount) int j = 0 ; j = FindCommandCounter WHILE (j <= 7) ; 8 commands for now ; ----------------------------------------------------------- Debug.trace("Searching for command " + s_CMD[j] + " beginning in SVE_Dump at index " +iCurrentSearchStart) ; ----------------------------------------------------------- ;; s_CMD[0] = "Thuum" ;; s_CMD[1] = "Equip" ;; s_CMD[2] = "Unequip" ;; s_CMD[3] = "Use" ;; s_CMD[4] = "Cast" ;; s_CMD[5] = "Map" ;; s_CMD[6] = "Save" ;; s_CMD[7] = "Exit" int iCMDFound = s_DA.Find(s_CMD[j], iCurrentSearchStart) ; ----------------------------------------------------------- Debug.Trace("SVE_TEST: Searching for executable command at position " +j) ; ----------------------------------------------------------- IF (iCMDFound >= 0) ; this cycles through the command form list (e.g. equip, use, cast, thuum, etc) ;;; CurrentCMD = s_DA[iCMDFound] ;;; Debug.Trace("Command found: " + s_DA[iCMDFound] + " in index " + iCMDFound) IF (j == 0) ; "Thuum" ;search next three indices for thuum words against Thuum formlist ;do all three words belong to the same thuum? ;how many words does the player know? ;shout ; --------------------------- ELSEIF (j == 3) ; "Use" ;potion formlist ; ---------------------------- ELSEIF (j == 4) ; "Cast" ;spell formlist ; --------------------------- ELSEIF (j == 5) ; "Map" ;int MapKey = Input.GetMappedKey("Quick Map",0x00) ;Input.TapKey(MapKey) ; ---------------------------- ELSEIF (j == 6) ; "Save" ;int SaveKey = Input.GetMappedKey("Quicksave",0x00) ;Input.TapKey(SaveKey) ; ---------------------------- ELSEIF (j == 7) ; "Exit" ;Debug.QuitGame() ; ------------------------------- ELSEIF (j == 2) ; "Unequip" ;iCurrentSearchEnd = myF_UnEquip() ; ----------------------------- ELSEIF (j == 1) ; "Equip" iCurrentSearchEnd = myF_CMD_Equip(iCMDFound) ENDIF ENDIF j = j + 1 ENDWHILE ; ----------------------------------------------------------- Debug.Trace("SVE_TEST: Updating variables for main loop..") ; ----------------------------------------------------------- iCurrentSearchStart = iCurrentSearchEnd ; endCMD i = i + 1 ENDWHILE ; ############# Debug.Trace("SVE_TEST: Command parser test complete in " + (Utility.GetCurrentGameTime() - StartTime) + " seconds.") Debug.Notification("Dumping SVE_Dump to Log") i = 0 WHILE (i <= 13) Debug.Trace("SVE_TEST: word " +i+ " " +s_DA[i]) i = i + 1 ENDWHILE ; ############# ENDFUNCTION ;--------------------------------- String FUNCTION myF_GetLine(Int n) ;--------------------------------- ;String FUNCTION GetLine(string SVE_PO,int CurrentLineNumber,int NumberOfLines) ; was called by "GetLine(CurrentDump, LoopCounter, DumpLineCount)" ; ******************************************************************************* ; *** I assume string "CurrentDump" has been declared on top as heap variable *** ; ******************************************************************************* n = n - 1 ; n = LinesToSkip int LineStartIndex = 0 string s ; s = LineReturn int i = 0 ; i = LinesSkipped WHILE (i <= n) int NullCharIndex = StringUtil.Find(CurrentDump, "/n", LineStartIndex) IF (NullCharIndex != -1) s = StringUtil.Substring(CurrentDump, LineStartIndex, NullCharIndex - LineStartIndex) LineStartIndex = NullCharIndex + 2 i = i + 1 ENDIF ENDWHILE RETURN s ENDFUNCTION ;----------------------------------------------------------- String FUNCTION myF_GetWord(String sLine, Int iWords, Int n) ;----------------------------------------------------------- ;String FUNCTION GetWord(String SVE_CurrentLine, int WordsOnLine, int WordNumber) ; was called by "GetWord(CurrentLine, WordsOnCurrentLine, CurrentWordIndex)" n = n - 1 ; n = WordsToSkip // this is incorrect e.g. on the first pass wordsonline==8, and wordnumber==1, but will skip 7 words. int WordStartIndex = 0 ; WordStartIndex = WordParserStart string s ; s = WordReturn int i = 0 ; i = WordsSkipped WHILE (i <= n) int EndSpaceIndex = StringUtil.Find(sLine," ", WordStartIndex) ; EndSpaceIndex = EndOfWord // accounting for space IF (EndSpaceIndex != -1) s = StringUtil.Substring(sLine, WordStartIndex, EndSpaceIndex - WordStartIndex) WordStartIndex = EndSpaceIndex + 1 i = i + 1 ENDIF ENDWHILE RETURN s ENDFUNCTION ;--------------------------------- Int FUNCTION GetNumWords(String s) ;--------------------------------- ;int function GetNumWords(string SVE_CurrentLine) ; was called by "GetNumWords(CurrentLine)" ;;; int NullCharIndex = StringUtil.Find(s, "/n", 0) ; UnUSED // Finds index of null character/end of line, start with zero int WordBeginningIndex = 0 ; index: beginning of the word int SpaceIndex = 0 ; index: end of the word int i = 0 ; i = WordCount WHILE (SpaceIndex != -1) SpaceIndex = StringUtil.Find(s, " ", WordBeginningIndex) ; " word1 ", "word2 " IF (SpaceIndex != -1) WordBeginningIndex = SpaceIndex + 1 i = i + 1 ENDIF ENDWHILE RETURN i ; number of words on the current line ENDFUNCTION ;----------------------------------- Int FUNCTION myF_CMD_Equip(Int iCMD) ;----------------------------------- ; iCMD = iCMDFound ; declarations out of loop ; ~~~~~~~~~~~~~~~~~~~~~~~~ string[] a = new String[10] ; a = Formulator ;;; string MaterialType ;;; string WeaponType ;;; string WeaponName ;;; string ArmorType ;;; string ArmorName ;;; string ItemFound string s ; s = iToParse // need to rename this, NOW it is! bool break = False int endCMD = s_DA.Find("QUICK", iCMD) ; try to find the string "QUICK" at position iCMDFound, return this value at the end int iCMDLength = endCMD - iCMD ; *** THIS LOOP IS NOT PERFECT !!! *** int i ; i = iItemFound int c = 0 ; c = CMDParserCounter WHILE (c <= iCMDLength) && (!break) s = s_DA[iCMD + c] ;; Debug.Trace("SVE_TEST: myF_CMD_Equip() - (" +s+")") ; -------------------- IF (!break) && (s_Material.Find(s) >= 0) break = TRUE a[0] = s_DA[iCMD + c] ; [0] MaterialType debug.trace("Material type detected at " + c) ENDIF ; -------------------- IF (!break) && (s_Weapon.Find(s) >= 0) break = TRUE a[1] = s_DA[iCMD + c] ; [1] WeaponType debug.trace("Weapon type detected at " + c) IF (sn_Weapon.Find(s) >= 0) a[2] = s_DA[iCMD + c] ; [2] WeaponName debug.trace("Unique weapon modifier detected at " + c) ENDIF ENDIF ; -------------------- IF (!break) && (s_Armor.Find(s) >= 0) break = TRUE a[3] = s_DA[iCMD + c] ; [3] ArmorType debug.trace("Armor type detected at " + c) IF (sn_Armor.Find(s) >= 0) a[4] = s_DA[iCMD + c] ; [4] ArmorName debug.trace("Unique armor modifier detected at " + c) ENDIF ENDIF ; -------------------- IF (!break) Debug.Trace("SVE_TEST: nothing found..") c = iCMDLength ; /// BREAK the loop /// ENDIF c = c + 1 ENDWHILE ; ========================== IF ( a[0] ) s = a[0] ; Material ENDIF IF ( a[1] ) s+= " " + a[1] ; Weapon type IF ( a[2] ) s+= " " + a[2] ; Weapon name ENDIF ENDIF IF ( a[3] ) s+= " " + a[3] ; Armor type IF ( a[4] ) s+= " " + a[4] ; Armor name ENDIF ENDIF ;;; a[5] = a[0]+" "+a[1]+" "+a[2]+" "+a[3]+" "+a[4] Debug.Trace("SVE_TEST: " +s) ;weapon or armor? ;armor/clothing ;should look for keywords like armor, breastplate, helmet, boots, gauntlets, cloaks, etc. ;this will be called piece ;modifier type will be called piecetype, this will be mostly materials ;expecting form "equip ebony armor", "equip dragonbone helmet", etc ;weapon ;name (staff of magus) ;material ;type (e.g. dagger, sword, greatsword, staff, bow, gloves) ;equipping hand ;expecting form "ebony bow and arrows", "or ebony bow and ebony arrows" ;expecting form "equip dragonsting dagger in left hand" ;expecting form "equip staff of magus in right hand", etc. RETURN endCMD ; see above code line "endCMD = s_DA.Find("QUICK", iCMD)" ENDFUNCTION Link to comment Share on other sites More sharing options...
irswat Posted November 11, 2016 Author Share Posted November 11, 2016 (edited) ReDragon: First of all I do want to say thank you so very much for taking God knows how much time in order to help me with this. First of all you should have more respect if somebody answers to your posting. Each nexus user spends time (spare time) to give you depends on his knowledge a best as possible answer/solution. I'm wondering if I have said something in a previous thread that you found to be offensive or disrespectful? ; the next loop is a bit strange because of twice Find(), should be carefully optimized (ReDragon 2016) If papyrus had do...while/while...do loops I could avoid the second Find(). As it stands the condition for entering the loop is at the beginning. Ideally it would be a do/while loop because the condition upon which the loop continges is within the loop. This particular function counts lines and without the additional Find to refresh NullCharIndex the loop would count one extra time, and would return one more line than it needs. I could just as easily just return LineCount-1, but this is the solution I opted for, it's less hacky. I hope that makes sense.You're right that I forgot to mention this script relies on SKSE as well as PapyrusUtil which has the function ReadFromFile(). It dumps a text file to a string. Very cool!I think your scripting style is very beautiful and clean.I''m importing StringsUtil because I will be using functions from it extensively, and it should improve access times of functions from that library. I didn't include MiscUtil because I will only be using the one function from it one time. It was a conscious choice.My apologies that the code is so unreadable. Prior to release, or if someone joins the team to help me make this voice engine I will focus more on in line commenting and better organization in functions. I like Main to be mostly the framework/logic consisting almost entirely of function calls and the logic that guides their execution. Once I get a couple more functions done I will take much of the code that is in main and compartmentalize each piece of code into functions in a logical and orderly fashion. Again thank you so much for taking time to re-write this, but please understand it will be very difficult to incorporate the changes you have made. I will better comment my code though if I ask for help again.As you noticed, after much testing I finally was able to find out what was going on, it was a hidden carriage return that I was capturing from the text file. The carriage return is no longer being captured, and the code is working as expected. Currently I'm working on the function that goes through the formlists and compares the form names to the commands being issued by voice command. Once I finish this I will work on executing the commands. Then I will incorporate the microsoft voice to text engine, and have a pre-alpha working concept to inspire some interest in the hopes that I could get another coder or two on board. If you're interested.Some interesting functions have resulted from my work so far including GetLine, GetNumLines, GetNumOfWords, and GetWord. All useful string functions. This next work I'm doing should yield two more interesting functions that could be added to SKSE: SearchFormList(string). It is passed a string and then searches a list of forms for a form name that most matches the string, and Intersect(string1, string2) which returns a percentage match for how much the strings match. ; ========================== IF ( a[0] ) s = a[0] ; Material ENDIF IF ( a[1] ) s+= " " + a[1] ; Weapon type IF ( a[2] ) s+= " " + a[2] ; Weapon name ENDIF ENDIF IF ( a[3] ) s+= " " + a[3] ; Armor type IF ( a[4] ) s+= " " + a[4] ; Armor name ENDIF ENDIF I really like this code. I might add this logic, in which case I would give you credit. I was thinking of ways to handle the extra spaces from empty strings earlier and i came up with a pretty good solution, to check whether they are empty before concatenating them! :-) Precisely what you did.When I learned computer programming, I'm not even sure threading existed. I did begin to read up on the idea. A lot of this code is serial. I think it would be possible to parse the commands in a threaded/parallel way. For example to parse all Commands in the string at the same time that way the instant one command is executed, the next is already to go. I like that idea a lot! Problem is I don't really know how to do this, except as a matter of parallel programming as a principle. P.S. I try to reciprocate by helping others where and when I can. thanks for showing interest!edit: in reply to your comment about heap variables. By heap variable you are referring to a global variable? Edited November 12, 2016 by irswat Link to comment Share on other sites More sharing options...
ReDragon2013 Posted November 14, 2016 Share Posted November 14, 2016 (edited) .. Edited March 6, 2017 by ReDragon2013 Link to comment Share on other sites More sharing options...
NexusComa Posted November 14, 2016 Share Posted November 14, 2016 (edited) Great work here on both your parts. Edited November 14, 2016 by NexusComa Link to comment Share on other sites More sharing options...
irswat Posted November 14, 2016 Author Share Posted November 14, 2016 thanks NC. Couldn't do it without help from people in the community like FF, Ishara, thepwn, exiledviper and ReDragon. Link to comment Share on other sites More sharing options...
Recommended Posts