GameMonkey Script

GameMonkey Script Forums
It is currently Tue Oct 23, 2018 5:17 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Feb 22, 2010 10:06 am 
Offline

Joined: Fri Feb 19, 2010 12:21 pm
Posts: 10
Note that the code I'll be using as reference is from the excellent GameDev introduction articles. Whoever wrote them -- thank you so extremely much!

Just looking at how the library entry function is shaped, anyway:

Code:
gmFunctionEntry lib[] =
{
   { "Vector", libentry }      // type name, entry point
};


Is it possible to register several function entries with a single library, like this:

Code:
gmFunctionEntry lib[] =
{
   { "Vector2", libentry },      // type name, entry point
   { "Vector3", libentry },      // type name, entry point
   { "Vector4", libentry }      // type name, entry point
};


...and, if it indeed is possible, how would the binding functionality have to be modified?


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 22, 2010 2:35 pm 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
That's fine. In the function you would just need to have a few branches based on a_thread->GetNumParams() to validate the args and push the right type for the return value.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 23, 2010 3:47 pm 
Offline

Joined: Fri Feb 19, 2010 12:21 pm
Posts: 10
I was wondering more about the VM-linking.

It looks like this in the GameDev article:

Code:
machine.RegisterLibrary( s_myLibrary, sizeof(s_myLibrary) / sizeof(s_myLibrary[1]), 0 );


How would I have to change that line to accomodate the multiple table entries?

Might be a question to an obvious answer, but anyway. ;)


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 23, 2010 5:31 pm 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
Code:
machine.RegisterLibrary( s_myLibrary, sizeof(lib) / sizeof(lib[0]), 0 );


will register 3 functions.

you don't need to change the register line when you add more lines to the gmFunctionEntry array. the sizeof bit handles the sizing

Code:
sizeof(lib) / sizeof(lib[0])
gives you the size of the statically allocated array(this technique doesn't work on dynamically allocated arrays).


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 23, 2010 6:13 pm 
Offline

Joined: Fri Feb 19, 2010 12:21 pm
Posts: 10
Thank you very, very much! =)

I'm still quite new to the ways of C++, I'm afraid. These kinds of questions may come up again. ;)


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 23, 2010 11:53 pm 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 707
I'm not a big fan of C style structure initialization and now prefer to call the
RegisterLibraryFunction() RegisterTypeLibraryFunction() functions repeatedly.
You can also make your own containers and automate registration somewhat.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 24, 2010 6:22 am 
Offline

Joined: Fri Feb 19, 2010 12:21 pm
Posts: 10
It's taken me a week or so, by now, but I'm actually up and running with more or less 100% of what I wanted a scripting language to achieve in the prototype I'm working on.

Huge kudos to you guys -- Game Monkey is simply great! I'll post something in the "what are you making with ..."-section when there are pretty screenshots to show. Until then -- five tons of Thank You!


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 26, 2010 5:00 am 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
good to hear! if you have any other questions feel free to stop by


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group