seems like if you want to set function arguments you have to know the type of the argument. but what if i don't know the type of the argument. there isn't any anonymous or template ctx→SetArg() function so what should i use. this is the code.
template<class... Args>
inline int callfunc(const char* funcdecl, asIScriptModule* module, asIScriptEngine* engine, Args... args)
{
// Create our context, prepare it, and then execute
asIScriptContext* ctx = engine->CreateContext();
asIScriptFunction* func = module->GetFunctionByDecl(funcdecl);
if (func != 0)
{
ctx->Prepare(func);
if constexpr(sizeof...(args) > 0)
{
int num = 0;
((ctx->SetArg(num++, args)), ...); //at first i thought it was SetArgDWord but that's for a Dword argument
}
int r = ctx->Execute();
if (r != asEContextState::asEXECUTION_FINISHED)
{
if (r == asEContextState::asEXECUTION_EXCEPTION)
{
printf("An exception '%s' occurred. Please correct the code and try again.\n", ctx->GetExceptionString());
}
}
// Clean up
ctx->Release();
return 1;
}
return 0;
}