GameMonkey Script

GameMonkey Script Forums
It is currently Mon Nov 20, 2017 3:24 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Sep 26, 2012 10:09 pm 
Offline

Joined: Sat Sep 01, 2012 3:12 am
Posts: 12
The problem I'm having is that I don't know how to get the base-object from the type-function. For instance:

Code:
void Register_Overlay_InGamemonkey_VM( gmMachine *vm )
{
   static gmFunctionEntry overlayFuncs[] = {
      { "on_draw", Overlay_OnDraw, NULL },
      { "show", Overlay_Show, NULL },
      { "hide", Overlay_Hide, NULL },
      { "primitive", Overlay_Primitive, NULL }
   };
   
   vm->RegisterTypeLibrary( vm->GetTypeId("Overlay"), overlayFuncs, 4 );
}


Here is the "show" code:

Code:
int GM_CDECL Overlay_Show(gmThread * a_thread )
{
   GM_CHECK_NUM_PARAMS(0);
   
   Overlay *ol = (Overlay *)a_thread->ThisUserCheckType( a_thread->GetMachine()->GetTypeId("Overlay") );
   if ( ol == NULL ) {
      GM_EXCEPTION_MSG( "Expected 'this' to be of user-type 'Overlay'" );
      return GM_EXCEPTION;
   }
   
   ol->visible(true);
   
   return GM_OK;
}


Then in game monkey:

Code:
print("Beginning test"); // Displays properly (I have a print callback setup)
test = Bear.window.getOverlay("test"); // Returns a Overlay-typed variable
test.show(); // Breaks the script
print( "test to see if the script has stopped or not" ); // Never gets displayed


There is no documentation on how to get the data stored in 'test' inside the 'show()' function.

Thanks for any help,
-MrBarry


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 29, 2012 2:33 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 698
Exactly what error messages are you seeing?

If you print the result of 'test = Bear.window.getOverlay("test")'
eg. print("test=",test")
What is do you see? We expect to see a pointer to user type 'Overlay'.

I don't quite understand what 'the data stored in 'test' inside the 'show()'' means.
'test' should be a gmUserObject. From that you would be able to access type bound functions like the ones you show. (They look fine to me.) To access data members, operator Get/SetDot must be implemented as gmUserObjects have none built in.

Edit: If you're asking how to access the Overlay members inside function show() (native function Overlay_Show()), what is the value of 'Overlay *ol' ? Is it valid or null?


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 29, 2012 3:51 am 
Offline

Joined: Sat Sep 01, 2012 3:12 am
Posts: 12
So I decided since I was already going insane, I walked my pop-can through my code, and realized that I did a mass copy/paste of my function assignments for one of my tables, and forgot to change the one that controls `Bear.window.overlay`

So oops, that was totally my mistake. :oops:

-MrBarry


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 29, 2012 6:11 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 698
Glad to hear you have it sorted.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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