Jump to content

[LE] SKSE plugin function: too many arguments passed to function


irswat

Recommended Posts

I created an SKSE plugin that receives one boolean arguement, and returns one string argument. The function is defined and declared as such. The plugin builds without any problems. When I try to call the function from papyrus i get the error:

C:\Games\steamapps\common\skyrim\Data\Scripts\Source\SVE_ParserEngine.psc(67,23): too many arguments passed to function
C:\Games\steamapps\common\skyrim\Data\Scripts\Source\SVE_ParserEngine.psc(76,23): too many arguments passed to function

here is the relevant code:

Event OnKeyUp(int keyCode, float holdTime)
	;debug.notification("Refreshing script.")
	bool ListenFlag=false
	if !(Input.IsKeyPressed(29))
		string HelloWorld=SKSE_SpeechRecPlugin.GetTextFromSpeech(false)
	endif
	
	RegisterForSingleUpdate(0.004)
EndEvent

Event OnKeyDown(int keyCode)
	bool ListenFlag=true
	if (Input.IsKeyPressed(29))
		string HElloWorld=SKSE_SpeechRecPlugin.GetTextFromSpeech(true)
	endif
	
	RegisterForSingleUpdate(0.004)
	
endEvent

and the c++ code for the plugin:

 

#include "SKSE_SpeechRecPlugin.h"
#include "voce.h"
#include "string.h"
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <fstream>

namespace SpeechRecNamespace {
	BSFixedString GetTextFromSpeech(StaticFunctionTag *base, bool Listening) {
		const char* c_GetSpeech = "";
		
		while (Listening == true)
		{
			while (voce::getRecognizerQueueSize() > 0)
			{
				std::string s_TextFromSpeech = voce::popRecognizedString();
				const char* c_GetSpeech = s_TextFromSpeech.c_str();

				std::fstream myfile("C:\Games\SteamApps\common\Skyrim\Data\SVE_PI.txt", std::fstream::in | std::fstream::out | std::fstream::app);
				if (myfile.is_open())
				{
					myfile << c_GetSpeech << "/n";
					myfile.close();
				}
			}

		}
		return BSFixedString(c_GetSpeech);
}
	bool RegisterFuncs(VMClassRegistry* registry) {
		registry->RegisterFunction(
			new NativeFunction1 <StaticFunctionTag, BSFixedString, bool>("GetTextFromSpeech", "SKSE_SpeechRecPlugin", SpeechRecNamespace::GetTextFromSpeech, registry));

		return true;
	}
}

 


the header:

#include "skse/PapyrusNativeFunctions.h"

namespace SpeechRecNamespace
{
	BSFixedString GetTextFromSpeech(StaticFunctionTag *base, bool);

	bool RegisterFuncs(VMClassRegistry* registry);
}


any idea why I can't seem to pass this function a bool?

 

Link to comment
Share on other sites

I was under the impression 0 is false, and 1 is true. I fixed the problem, I had neglected to declare my variable in the papyrus declaration script:

scriptName SKSE_SpeechRecPlugin Hidden

float Function GetTextFromSpeech(int bFlag) global native

I'm toying with how to get the speech recognition libraries working. Voce seems very simple. I hope this works! If so the skyrim community with have a voice command engine for skyrim that is orders of magnitude better than the ones that are already out there!

Link to comment
Share on other sites

try the test above

 

int Test = -1

 

If(Test==true)
bla bla bla
endif
or Debug.MessageBox(True)
It really all comes down to how the code is wrote at the assembler level
ie: 0 is false , anything not 0 is true
or -1 is true and 0 is false
In assembler the default of true as a function is -1
However, you can test for if the number is filled with a value as in it's not 0 and it may seem like you're testing true but it's
really not the function "true" ... The higher level the language the more you see this ...
In papyrus I'm sure "true" may very well be 1.
I just always myself use -1 as I started programming in assembler.
This test here will tell the tale ... Debug.MessageBox(True)
That is the best way to see how your language looks at "true".
If I had to guess the problem most likely is you're creating a sub complied part of the code with the extension,
and the values for true and false are not added until the 2nd pass in the compiler. By then it has already created a syntax error
that was over looked by the 1st pass but will show up when ran from the script itself.
Edited by NexusComa
Link to comment
Share on other sites

  • Recently Browsing   0 members

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