Advertisement

"global" and "static" module

Started by August 17, 2013 11:04 AM
2 comments, last by WitchLord 11 years, 3 months ago

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!!

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 Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

Advertisement

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

[size="1"]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!

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

This topic is closed to new replies.

Advertisement