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.


- - - - -

"global" and "static" module


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
3 replies to this topic

#1 Bow_vernon   Members   -  Reputation: 137

Like
0Likes
Like

Posted 17 August 2013 - 05:04 AM

Hi all, I have a problem now. I design that in the game, I'll have one global module (that is where I store functions that another module can call), and many "static" module. I need the "static" module to be able to refer to the "global" module such as :

//global.as
//this is where I define a set of "default" function
void def_item_drop_behavior()
{
  //do something generic
}


//sword.as

void on_drop()
{
  //do something that is "sword" specific
  blah();
  //do something that every item would do when dropped
  def_item_drop_behavior();
}

//potion.as

void on_drop()
{
 //do something "potion" specific
 blah();
 //do something that every item would do when dropped
  def_item_drop_behavior();
}

now I'm at lost at how I'm supposed to do this. Any insight?

 

EDIT : I'm using angelscript of course, I recently see the sample on the SDK. The #include sample basically, it allowed me to reuse code, but I don't want to duplicate variables. I need the variables in the "global" module to be shared/referenced by the other script. That's what I'm pursuing.

 

I'm rethinking my approach now, so feel free to give suggestions. Thanks a bunch!!


Edited by Bow_vernon, 17 August 2013 - 11:46 AM.


Sponsor:

#2 SillyCow   Members   -  Reputation: 885

Like
0Likes
Like

Posted 17 August 2013 - 05:46 AM

Not sure what you are asking, but I'll take a shot.

 

Assuming this is actionscript, You probably need to read up on "package" and "import" commands.

Create a global package (global.as) , then import it in every module (sword.as)


My new android game : Enemies of the Crown

My previous android game : Killer Bees


#3 SimonForsman   Crossbones+   -  Reputation: 6189

Like
0Likes
Like

Posted 17 August 2013 - 08:32 AM

Not sure what you are asking, but I'll take a shot.

 

Assuming this is actionscript, You probably need to read up on "package" and "import" commands.

Create a global package (global.as) , then import it in every module (sword.as)

 

Its in the angelcode forum so its most likely AngelScript


I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#4 Andreas Jonsson   Moderators   -  Reputation: 3417

Like
1Likes
Like

Posted 18 August 2013 - 04:02 AM

You can use function imports to accomplish this.

 

In your "static" modules add the following:

 

import void def_item_drop_behavior() from "global";

 

When the application compiles the "static" modules it must call the method BindAllImportedFunctions on the module after the build completes.

 

You may also want to read up on shared entities, with which you can share classes and interfaces between modules so you don't have to work with just primitives and registered types in the imported functions.

 

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




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