• Create Account

## AngelScript 1.8.0 WIP #2 (2004/06/26)

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

47 replies to this topic

### #1Andreas Jonsson  Moderators

Posted 11 June 2004 - 10:38 AM

Hi guys, I've just released the first work-in-progress version of 1.8.0. You can find it and the description of its changes here: http://www.angelcode.com/angelscript/wip.asp Regards, Andreas Jönsson Author of AngelScript __________________________________________________________ www.AngelCode.com - game development and more... AngelScript - free scripting library - Tower - free puzzle game <SPAN CLASS=editedby>[edited by - WitchLord on June 11, 2004 5:39:04 PM]</SPAN> [Edited by - WitchLord on June 26, 2004 2:16:32 PM]
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #2Malmer  Members

Posted 11 June 2004 - 01:41 PM

Just make sure performance is not taking a hit with the new features. Performance is key to a scripting language used in games.

Posted 11 June 2004 - 06:31 PM

You can eventually call it Angel C++ :D. Anyway as for the other post the 1.7.1a in .NET (i dont have 2003 ) it asks me for a .rc/.res file during compile, so i guess you should check this out, the only way i could fix it was copy the .rc file and recompile (with version changes). i dont know if this is required, but i guess you should try it in .NET sometime to confirm.

Later

Jayanth.K
Raptor Entertainment Pvt. Ltd.
http://www.raptorentertainment.com

### #4Andreas Jonsson  Moderators

Posted 12 June 2004 - 05:10 AM

Malmer:

I''m not adding anything that should change the performance. It will just be more flexible.

Did you note a difference in performance? Perhaps you are compiling the library in debug mode?

I think the problem is not with .NET but with the project file I was distributing. It was referencing a resource file, but I didn''t include the resource file in the distribution. You ought to be able to just remove the reference to the resource file and it should work.

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game

Posted 13 June 2004 - 09:55 PM

Just make sure teh reference is not present in 1.8.0. just to avoid confusion.

Jayanth.K
Raptor Entertainment Pvt. Ltd.
http://www.raptorentertainment.com

---------------------------------------------------------
The blue pill was a placebo!

### #6Andreas Jonsson  Moderators

Posted 26 June 2004 - 08:16 AM

I've updated the WIP

http://www.angelcode.com/angelscript/wip.asp

Not too much has changed though as I haven't had the time to really work on AngelScript for the last two weeks.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #7Anonymous Poster_Anonymous Poster_*  Guests

Posted 26 June 2004 - 09:15 AM

problem using the WIP... Everything links fine and everything, but I get this error when creating the scripting engine (I based everything I did off the sample program):

Failed to create script engine - Expecting library version 1.6.1, found 1.8.0 WIP 20040611

I compiled and linked to the WIP lib. I then included the WIP angelscript.h header. I don't think I am mixing the two versions. Any help?

### #8Andreas Jonsson  Moderators

Posted 26 June 2004 - 01:52 PM

I think you just need to recompile the application. First clean target files to make sure the compiler really compiles all of the modules.

You said you updated the angelscript.h file, but your application is still expecting version 1.6.1. This tells me that the application wasn't compiled with the new angelscript header.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #9Anonymous Poster_Anonymous Poster_*  Guests

Posted 27 June 2004 - 09:37 AM

Problem with registering global functions...

the functions are defined like so:
void GetAndReleaseKey(int key);
void GetKey(int key);
void ReleaseKey(int key);

then I try to register them:
r = engine->RegisterGlobalFunction("void GetAndReleaseKey(int)", asFUNCTION(GetAndReleaseKey), asCALL_CDECL); assert( r >= 0 );
r = engine->RegisterGlobalFunction("void GetKey(int)", asFUNCTION(GetKey), asCALL_CDECL); assert( r >= 0 );
r = engine->RegisterGlobalFunction("void ReleaseKey(int)", asFUNCTION(ReleaseKey), asCALL_CDECL); assert( r >= 0 );

and I get this error message:
....
Debug Error:
....
file: "i386\chkesp.c"
Line 42
The value of ESP was not saved properly accross a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with another calling convention.

So, anyone know what's wrong?

Here is how I set up my engine and everything:
engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
if( engine == 0 ) { hge->System_Log("Failed to create script engine"); hge->System_Log("- Expecting library version %s, found %s", ANGELSCRIPT_VERSION_STRING, asGetLibraryVersion()); return -1; }

### #10Andreas Jonsson  Moderators

Posted 27 June 2004 - 11:39 AM

Do you get the error message when you try to register the functions, or when your script is calling the registered functions?

If it is when you register the functions then something is seriously wrong. It might even be a bug in AngelScript.

If it is when your script is calling the function then perhaps your functions aren't really using the cdecl calling convention. Try declaring the functions with the __cdecl modifier, or if that doesn't work with extern "C".

If you compile the test frame work (available from the WIP page) do you get the same errors?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #11Anonymous Poster_Anonymous Poster_*  Guests

Posted 27 June 2004 - 02:34 PM

I compiled the test framework and it just comes up with press any key to quit. The error occurs when I try to register the function, not call it. Tell me, what steps do I need to take before I can start registering functions?

### #12Andreas Jonsson  Moderators

Posted 28 June 2004 - 07:03 AM

Since the test framework passed all the tests without any errors at least I know the library is working ok.

The only thing you should have to do before registering functions is to create the engine. Take a look at the source code for the test framework for individual examples showing how to register functions.

I'm thinking that you are having a linkage problem. Somehow your application is not using the same interface or calling convention that the library is. Are you the same Anonymous Poster that was previously using version 1.6.1?
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #13Anonymous Poster_Anonymous Poster_*  Guests

Posted 28 June 2004 - 08:24 AM

yes. I guess I will just erase everything angelcode and install it again. I'll let you know what happens.

### #14Anonymous Poster_Anonymous Poster_*  Guests

Posted 28 June 2004 - 09:09 AM

Yep, I accidentally was mixing the different versions. But, now I have another error (and only one version of angelscript). When I try to register a classes' methods, I get
assertion errors. The registering of stuff is in a different source file, but includes a global header containing the various class definitions.

the registering:

r = engine->RegisterObjectMethod("CGame", "int AddFont(char *filename)", asMETHOD(CGame::AddFont), asCALL_THISCALL); assert( r >= 0 );
r = engine->RegisterObjectMethod("CGame", "int AddAnim(char *filename, int frames, int width, int height)", asMETHOD(CGame::AddAnim), asCALL_THISCALL); assert( r >= 0 );
r = engine->RegisterObjectMethod("CGame", "int AddSound(char *filename)", asMETHOD(CGame::AddSound), asCALL_THISCALL); assert( r >= 0 );

### #15Andreas Jonsson  Moderators

Posted 28 June 2004 - 10:53 AM

What WIP version are you using?

With the latest you should take the method pointer with asMETHOD(classname, methodname).

What is the value of r that you receive? Check the value and compare with error codes in angelscript.h.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #16Anonymous Poster_Anonymous Poster_*  Guests

Posted 28 June 2004 - 11:54 AM

http://www.angelcode.com/angelscript/files/angelscript_sdk_180WIP_20040626.zip

Either I downloaded the wrong WIP, or you forgot to update the zip file.

### #17Anonymous Poster_Anonymous Poster_*  Guests

Posted 28 June 2004 - 12:12 PM

Oh, I guess I'm using the right one. The error code is -11 or asINVALID_TYPE.

here is how I register the function:
r = engine->RegisterObjectMethod("CGame", "int AddFont(char *filename)", asMETHOD(CGame, AddFont), asCALL_THISCALL); assert( r >= 0 );

Does the class I'm referencing need to be an actual class or an object?

### #18Andreas Jonsson  Moderators

Posted 28 June 2004 - 12:45 PM

Since you get asINVALID_TYPE I assume that you haven't registered the CGame object type.

engine->RegisterObjectType("CGame", sizeof(CGame), flags);

or

engine->RegisterObjectType("CGame", 0, 0);

The second variant prevents the script from instantiating variables of that type, effectively forcing the script to use CGame objects provided by the application either through a global variable or a function.

If you choose the first variant you should read the reference about what the last parameter should be (flags).
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #19Anonymous Poster_Anonymous Poster_*  Guests

Posted 28 June 2004 - 03:12 PM

I'm sorry that I'm retarded but I can't get this to work. You were right I forgot to uncomment the line registering the CGame type. Now, I get error 10 (asINVALID_DECLARATION). Here is how it happens:

r = engine->RegisterObjectType ("CGame", 0, 0); hge->System_Log("%d", r); assert( r >= 0 );
r = engine->RegisterObjectMethod("CGame", "int AddSound(char*)", asMETHOD(CGame, AddSound), asCALL_THISCALL|asCALL_RETURNBYVAL); hge->System_Log("%d", r); assert( r >= 0 );

### #20Andreas Jonsson  Moderators

Posted 29 June 2004 - 01:31 AM

No worries :)

This time your problem is that you are trying to declare the method parameter as "char*", which isn't recognized by AngelScript. You could however use either one of int8, uint8, or bits8.

I suspect that you wish to be able to send a string to this function, in which case you will have to register a string factory function. If you don't register the string factory, AngelScript won't let you use the string constants. Take a look at the code for registering the bstr for more info on how to do that. You can even use that code directly in your application.

Register bstr source

If you decide to use the bstr code as it is, you'll have to remember to release the bstr that you receive. Or you could change your method to accept a reference to a bstr, as the script engine will be responsible for releasing the memory. I suggest you do the following:

#include "bstr.h"RegisterBStr(engine);engine->RegisterObjectMethod("CGame", "int AddSound(const bstr &)", asMETHOD(CGame, AddSound), asCALL_THISCALL);

Where the AddSound method looks like this:

int CGame::AddSound(const asBStr *_str) // Or char **{  // Dereference the parameter. By receiving the string by  // reference we don't have to deallocate the memory.   char *str = *_str;   // Continue working with str just as you would normally do  ...}

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.