Jump to content

[LE] How to return a blank form?


irswat

Recommended Posts

It's some what trivial but when my parser can not find a form that matches any of the words of a voice command, I would like to return null, or a blank form. When I try FormToReturn="", this gives me errors. When I created a blank form called SVCE_BlankForm and try returning FormToReturn=0511F099, this also does not compile.

Is there a way to return a blank form, or a null form?

Link to comment
Share on other sites

	counter3=0
	MatchingWords=TalleyofMatchingWords[LoopCounter]
	ListOfMatchingPercentages[LoopCounter]=(((MatchingWords as float/LengthOfCMDItem as float) * 100) as float)
		

	while counter3<=FormListSize
		if ListOfMatchingPercentages[counter3]>tempWinner
			tempWinner=ListOfMatchingPercentages[counter3]
			itempWinner=counter3
			GreatestMatch=TalleyofMatchingWords[itempWinner]
		endif
		counter3+=1
	endwhile
	
	if OverLoadSwitch=="Weapon"
		FormToReturn=WeaponFormList.GetAt(itempWinner)
		MatchFound=true
	elseif OverLoadSwitch=="Potion"
		FormToReturn=PotionFormList.GetAt(itempWinner)
		MatchFound=true
	elseif OverLoadSwitch=="Armor"
		FormToReturn=ArmorFormList.GetAt(itempWinner)
		MatchFound=true
	elseif OverLoadSwitch=="Spell"
		FormToReturn=SpellFormList.GetAt(itempWinner)
		MatchFound=true
	elseif OverLoadSwitch=="Arrow"
		FormToReturn=AmmoFormList.GetAt(itempWinner)
		MatchFound=true
	endif
	
	if GreatestMatch==0
		FormToReturn=Game.GetForm(0x0511F099)
	endif

form to return is a form. The problem was I found a bug in the code. it's a voice command engine and the engine was issued a nonsensical command. I thought it was a bug in this code here, and it partially is. What was happening is the function that extracts words from the voice command dump was not resetting the curCMDfromDump variable. So when I issued a command "use frostbite venom", the word "use" goes in curCMDfromDump. This command parsed and executed correctly, but the next cmd was nonsense. It was supposed to be "sheath quick" but windows SAPI thought I said "she's quick". The "use" CMD was still in curCMDfromDump from the previous command "use frostbite venom". Consequently the parser was expecting to find a potion, but the only thing to parse was "use". When no match was found it returned index 0 from the PotionsFormList, which is potion of minor healing. Solution was two parts: reset curCMDfromDump after every loop, and if there are 0 matching words simply return a blank form.

 

hope that makes sense.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...