Advertisement

Copy Module. How?

Started by June 27, 2007 03:20 PM
5 comments, last by russian 17 years, 5 months ago
I have the module "mod1". How to me to create an exact copy of the module, but with other name "mod2"?
There's currently no automatic way of cloning a module. You'll either have to add the same script sections to another module and build it again, or you can save the bytecode of the first module to memory and then reload it under a different module name.

I do however intend to create a CloneModule method, which should be able to take advantage of the fact that the byte code for both modules is likely to be identical, thus reduce memory consumption.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Still a question on modules:
Why the quantity of modules is limited 0x3FF? At me on everyone NPC the separate module (it because of global variables, is a pity that Context does not allow it) is created.
Whether it is necessary then to create the second, the third... ScriptEngine?

Whether search of the module not by name, and on an index (at a plenty of modules it is very actual) Will be realized?
Hmm..

I don't think you'll want to use that many modules. You would be eating up an increadible amount of memory that way. You may want to rethink your design to share modules between your NPCs, e.g. instead of using global variables declare a script class with your NPC script variables and store a pointer to the class with the engine entity.

Think of a module as a DLL (or a .so in case you're on *nix). You wouldn't want to load one module for each game entity into memory.

Anyway, I'll try to remove the limit for modules. The limit was there because the module id was baked into the function ids before, but I'm moving away from that. When that's done there won't be a limit to the number of modules anymore.

What kind of search do you need for the modules?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Quote: Original post by WitchLord
Hmm..

I don't think you'll want to use that many modules. You would be eating up an increadible amount of memory that way. You may want to rethink your design to share modules between your NPCs, e.g. instead of using global variables declare a script class with your NPC script variables and store a pointer to the class with the engine entity.

Think of a module as a DLL (or a .so in case you're on *nix). You wouldn't want to load one module for each game entity into memory.


I shall think above it.

Quote:
Anyway, I'll try to remove the limit for modules. The limit was there because the module id was baked into the function ids before, but I'm moving away from that. When that's done there won't be a limit to the number of modules anymore.

What kind of search do you need for the modules?


At each module is Id. Why to not allow to address on it. It will be faster than to search for the module on a string.


The bug is found:
GetGlobalVarPointer(GetGlobalVarIDByName(module, name));
will work provided that module == NULL, since GetGlobalVarPointer(int gvarId) gvarId:
0x03FF0000 - module id,
0x0000FFFF - var id.
And GetGlobalVarIDByName returns only 0xFFFF, where module id???

EDIT:

now:
int asCModule::GetGlobalVarIDByName(const char *name){	[skip]		if( scriptGlobals[n]->name == name )		{			id = (int)n;			break;		}	[skip]}


maybe:
int asCModule::GetGlobalVarIDByName(const char *name){	[skip]		if( scriptGlobals[n]->name == name )		{			id = (int)n | this->moduleID;			break;		}	[skip]}

And in this too:
  int GetFunctionIDByDecl(const char *module, const char *decl);
I agree. I could allow setting module by id instead of by name. Maybe for 2.9.0.

The bug you mentioned have already been fixed in the SVN. I suggest you download the head version from SVN, quite a lot of bugs have been fixed since 2.8.0.

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

Advertisement
Ok, thanks for attention.

This topic is closed to new replies.

Advertisement