Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


- - - - -

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.

  • You cannot reply to this topic
47 replies to this topic

#41 Andreas Jonsson   Moderators   -  Reputation: 3442

Like
Likes
Like

Posted 03 July 2004 - 11:39 AM

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

Sponsor:

#42 Ped Xing   Members   -  Reputation: 122

Like
Likes
Like

Posted 03 July 2004 - 01:16 PM

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?

#43 Andreas Jonsson   Moderators   -  Reputation: 3442

Like
Likes
Like

Posted 03 July 2004 - 02:23 PM

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

#44 Ped Xing   Members   -  Reputation: 122

Like
Likes
Like

Posted 03 July 2004 - 03:44 PM

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)




#45 Andreas Jonsson   Moderators   -  Reputation: 3442

Like
Likes
Like

Posted 03 July 2004 - 03:57 PM

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

#46 Ped Xing   Members   -  Reputation: 122

Like
Likes
Like

Posted 03 July 2004 - 04:25 PM

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).



#47 EddHead   Members   -  Reputation: 140

Like
Likes
Like

Posted 03 July 2004 - 05:51 PM

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.

#48 Andreas Jonsson   Moderators   -  Reputation: 3442

Like
Likes
Like

Posted 04 July 2004 - 02:16 AM

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 type
r = 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 normally
r = 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




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.



PARTNERS