• Advertisement
Sign in to follow this  

Script isn't building

This topic is 3686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to integrate Angelscript into one fo the DX9 Samples, it's been a long time since I last used Angelscript. I had to compile the libs as a Multi-Threaded as opposed to a Multi-Threaded DLL to get it to compile with the DX Sample. then I loaded the script, Building the script crashes as it returns -1. AddScriptSection worked and I'm sure I'm passing the script properly! the script just has a main functions, so I'm sure there's no binding problems. How do I get more information about the script failure, and what could the problem be?

Share this post


Link to post
Share on other sites
Advertisement
You can use asIScriptEngine::SetMessageCallback() to set a callback function that will give you information on build errors. An example for using it appears in the tutorial sample in the SDK download.

Share this post


Link to post
Share on other sites
yep, got that working, but my script now isn't working. I get this error, but the PrintString function is very much there. The DX App uses Unicode, is there some probable conflict?

script (3, 5) : ERR : No matching signatures to 'print(string@&)'

Share this post


Link to post
Share on other sites
Quote:
Original post by Jayanth Kannan
yep, got that working, but my script now isn't working. I get this error, but the PrintString function is very much there. The DX App uses Unicode, is there some probable conflict?

script (3, 5) : ERR : No matching signatures to 'print(string@&)'


I may be interpreting your post wrong, but you're calling the function print from inside your script, so there must be a script function registered to that name.

is PrintString the in-script name of the function, or the C++ name?
maybe post the lines used to register the function as well?

Share this post


Link to post
Share on other sites
Alright, I figured out all my newbie problems, got it running quite well in my game now. what is the best way to debug/trace through the script functions just as you would through say - a C++ IDE?

Share this post


Link to post
Share on other sites
Debugging via breakpoints etc is complicated because that means you'd have to implement support for this in the game, i.e. an interface for displaying script code and variables etc.

Tracing however is simple, as it can be done in the background without affecting the game engine much.

The AngelScript interface is the same for both options though. I suggest you take a look at the tests/test_feature/source/test_debug.cpp test. It shows a good way of tracing the script execution by printing the execution path, complete with function names, line numbers, and variable values.

It's all done by setting a line callback on the context, and in the line callback you call the various context methods for inspecting the callstack and the variables.

Share this post


Link to post
Share on other sites
just started working with this after a long time, Nice to hear back from you Andreas - Remember me from a few years ago - from Raptor Entertainment....we had used your scripting engine in one of our games' render cycles to test performance as well as a general use throught, I'm back to using it now for more games, just getting back to it after a long time - a bit rusty right now.

Thanks for a great Library, I'll keep you posted as I use it. I just needed this feature to help out my Level designers as they'll be made to write script files as well.

Share this post


Link to post
Share on other sites
Ah, Raptor Entertainment, of course I remember. You were one of the firsts to really use AngelScript. Though I believe you ended up cancelling your game, right? Instead you seem to have moved onto licensing your 3D engine. Is the XForce engine using AngelScript?

I'm glad you're coming back to AngelScript again. Let me know when you have something to show, so I can add it to the users list.

Also, don't forget to tell me if you think there is anything missing from the library. I'm still working on it constantly, so feature requests are very welcome.

Regards,
Andreas

Share this post


Link to post
Share on other sites
yes we cancelled our Game because we had to refocus our company strategy. We are not yet into Engine licencing as we use our Engine to develop games and products for other companies now. and yes, Angelscript is now a part of our Engine. it wasn't carried over earlier from the Game. we're in the process of the next iteration of the engine, which is why I am firm on using AS as our scripting tool.

Share this post


Link to post
Share on other sites
bstr was very comfortable before, how can I get multiple strings into a bound function now?

I need it to work as multiple parameters(could be any combination)? could you explain how this is best implemented? the present implementation is like this, which compiles but doesnt work.
-------------------------------------------------------------------------------

int ScriptBinder::CreateInstance( asIScriptGeneric *gen )
/*int mesh, asIScriptGeneric *gen ,
float _11 , float _12, float _13, float _14,
float _21 , float _22, float _23, float _24,
float _31 , float _32, float _33, float _34,
float _41 , float _42, float _43, float _44 )*/
{

int mesh = *(int*)gen->GetArgPointer(0);
asCScriptString *arg1 = *(asCScriptString**)gen->GetArgPointer(1);
WCHAR wcUniqueName[BUFFER_SIZE] = L"";
mbstowcs(wcUniqueName, tempStr.c_str() , strlen(tempStr.c_str()) * 2 );

// read the Matrix
D3DXMATRIX tmp;
for(int i=2;i<2+16;i++)
tmp[i-2]=*(float*)gen->GetArgPointer(i);

return AddInstanceOfMesh( mesh, tmp, 0.0f, wcUniqueName );

}

-------------------------------------------------------------------------------
scriptengine->RegisterObjectMethod("ScriptBinder", "int CreateInstance( int mesh, const string &in, float , float , float , float , float , float , float , float , float , float , float , float , float , float , float , float )", asMETHOD(XScriptBinding, CreateInstance), asCALL_GENERIC);

-------------------------------------------------------------------------------
Error Message at as_context.cpp line 3429.
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

[Edited by - Jayanth Kannan on November 5, 2007 7:55:56 AM]

Share this post


Link to post
Share on other sites
I think your problem is using asMETHOD with asCALL_GENERIC. Methods can only be bound using asCALL_THISCALL. If you want to use asCALL_GENERIC, you'll need to make it a static method. The "this pointer" can be retrieved from the asIScriptGeneric paramater.

Share this post


Link to post
Share on other sites
I tried using THISCALL before this, All I get is an error message as indicateed. Please guide me to an explanation of how to handle parameters (single or multiple) that include strings, the way bstr used to work.

Share this post


Link to post
Share on other sites
You would get 'The value of ESP was not properly saved across a function call' if the calling convention isn't correct.

The code snippet that you showed in the post has various problems, though it would seem to be due to mistakes when copying the code to the post, since I hardly believe the code would compile the way it is.

- You're using a tempStr variable that isn't declared. Is this a global variable? If it is, why aren't you using the string variable that you retrieved from the generic interface?
- When binding the method you're using to asMETHOD(XScriptBinding, CreateInstance), but the code above says ScriptBinding::CreateInstance. The X is different.
- asCALL_GENERIC cannot be used with asMETHOD, as it expects a global cdecl function with the following signature: void function(asIScriptGeneric *gen)

Can you post a true copy of the code that present the ESP problem? I'm pretty sure you're getting it due to incorrect registration, rather than a problem with asCScriptString itself.

I'm pleased to hear you're decided on continuing use of AngelScript.

Regards,
Andreas

Share this post


Link to post
Share on other sites
I'll post the code in a while, Actually bstr works pretty fine for me, could you tell me the disadvantages of using bstr so that I may keep a lookout for the future?

Share this post


Link to post
Share on other sites
How can I maximize the Script engine's usability. can I add new functions via AddScriptSection after a build has taken place and context has been created. It doesnt seem to be workin when I crete a new context all the earlier compiled functions are forgotten.

All I want to do is to create different functions in different files which should be a part of the same module, and every function should be available. help me with this please.

Share this post


Link to post
Share on other sites
Every time Build() is called all the script sections are compiled and then removed. If you want to rebuild the module you'll have to add all the script sections again.

Note, you can add more than one script section to the module before building it.

Share this post


Link to post
Share on other sites
Thanks. I had forgotten about this, will have to change my implementation architecture a bit.

I'm getting this error for a totally harmless function though. which seems to work fine when I call it from the CPP file instead.

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.


Any ideas why this occurs?

Share this post


Link to post
Share on other sites
This happens when the function that is being called by AngelScript is not registered properly so that AngelScript doesn't call it the way the application expects. If the function expects any non-primitive types you need to check you registered those types as well as that can affect how the application expects the parameters.

Can you show me how you registered the function, and the function signature in the application?

Share this post


Link to post
Share on other sites
here you go

r = scriptengine->RegisterGlobalFunction("void SetCameraPos(float, float, float)", asFUNCTION(SetCameraPos), asCALL_STDCALL); assert( r >= 0 );

and the function

void SetCameraPos(float x, float y, float z)
{
D3DXVECTOR3 look = D3DXVECTOR3(x,y,z) + *g_Camera.GetWorldAhead();
g_Camera.SetViewParams( &D3DXVECTOR3(x,y,z), &look );
}


---------------------

a very simple function actually. a lot of other functions are working correctly.


Share this post


Link to post
Share on other sites
my 5 cents.

I've got the same error (Run-Time Check Failure #0 ...) inside my message callback function.

_AS_engine->SetMessageCallback(asFUNCTION(_AS_message_callback), &_err_log, asCALL_STDCALL);

the function is:

void _AS_message_callback(void* param1, void* param2);

there was no such error in AS 2.7.1b.

Share this post


Link to post
Share on other sites
Jayanth and mono2k:

Are you certain that your functions are using the __stdcall calling convention? By default the compilers usually use __cdecl, though you may have changed your settings. For the sake of eliminating possiblities, could you try registering your functions with asCALL_CDECL instead of asCALL_STDCALL?

By the way, what compilers are you using?

Share this post


Link to post
Share on other sites
Visual C++ .NET 2005, soon to be moving to 2008. I'm sure i'm following the right conventions, because it works for other similar functions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement