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

Started by
46 comments, last by WitchLord 19 years, 9 months ago
Ped Xing:

Welcome aboard. It's good to have a name to refer to, instead of just Anonymous Poster :)

Ok, in the last source you sent me I saw the error. You are searching for a function by "void main(void)". It's a syntax error to use void for parameters. Try "void main()" instead and I think you'll get a valid function ID.

The program crash you were getting was because you were calling Prepare() with the negative function ID. That was a bug in AngelScript that I've found and fixed. The fix will be in the next WIP version.

Regards,
Andreas

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

Advertisement
int function = engine->GetFunctionIDByDecl("", "void main()");

this call still makes function -1. Are there any headers or anything I need to put in the script file?
Strange.

Would you mind downloading WIP #4, so that we are working on the same version? I released this version about an hour ago.

I fixed a bug in the Build() method, that may be related to your problem.

I just noticed another problem in your script file. You've declared the script function as "void main()" yet your implementation returns 0. This is an error and makes the Build() fail. The bug I fixed is that the Build() function could at times report success even though it failed.

I suggest you add an output stream when calling the Build() function, that would allow you to catch any errors in the script.

class COutStream : public asIOutputStream{public:  void AS_CALL Write(const char *text) { printf(text); }};COutStream out;r = engine->Build(module, &out);if( r < 0 ){  // failure}

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

dude, it works! You're right, I put return 0; when it should have been return. More problems though. When I add in the COutStream code my program gives me this error:

Quote:
error LNK2001: unresolved external symbol "public: virtual void __stdcall COutStream::Write(char const *)" (?Write@COutStream@@UAGXPBD@Z)


The linker can't find your implementation of the COutStream::Write() method. Try putting the implementation outside the class declaration.

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

also, I am still a little confused about letting the scripting engine directly acces objects in my game.
like if I have a struct

struct point
{
int x, y;
};

point *p = new (point);

r = engine->RegisterObjectType ("point", 0, 0);
r = engine->RegisterGlobalPropery ("p", p);

how can I get the engine to use the actual instance of an object than just a class? I really don't know how to explain it or what I am talking about (need to work on my vocabulary).

I understand that it's all relative to the script. perhaps each section should be in a seperate file.

Thanks
Jayanth.KRaptor Entertainment Pvt. Ltd.http://www.raptorentertainment.com---------------------------------------------------------Why Mr. Anderson? Why? ...Why keep fighting? Do you think you're fighting for something - for more than your survival? Can you tell me what it is? Do you even know? Is it freedom, or truth, perhaps peace, could it be for love? Illusions Mr. Anderson, vagaries of perception. Temporary constructs of a feeble human intellect trying desperately to justify an existence without meaning or purpose.
EddHead:

That would be the easiest way to solve it.

Ped Xing:

You're almost doing it correctly already.

struct point{  int x, y;};point *p = new point;// stddef.h declares the offsetof() macro#include <stddef.h>// Register the typer = engine->RegisterObjectType ("point", sizeof(point), 0);r = engine->RegisterObjectProperty("point", "int x", offsetof(point, x));r = engine->RegisterObjectProperty("point", "int y", offsetof(point, y));// Register a global property that can be accessed normallyr = engine->RegisterGlobalPropery("point p", p);


When you register a property you should send a pointer to the property as the second argument. In this case I'm registering a global point, and send a pointer to a point.

You can also register the properties as const so that the scripts can't change the values. Just put const in the declaration, just like in C++.

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

This topic is closed to new replies.

Advertisement