Jump to content
  • Advertisement
Sign in to follow this  

Q about how AngelScript works

This topic is 4719 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

To start angel script you create an engine, then load scripts into modules (or a single module) Then when you wish to execute a script function you create a context to execute the function in. Here is my question. Does this context have it's own set of global variables and functions, or is this context just used to contain the calling of the function. Globals are still common to all. From what i've read it seems the latter. What i'm after is a way to have per entity data contained in the script. I'm new to scripting so excuse my ignorance. --Zims

Share this post


Link to post
Share on other sites
Advertisement
If you have exactly one entity per script, you can just use globals in the script. If multiple entities use the same script, you'll need to devise some way to store the data in the entity.

Share this post


Link to post
Share on other sites
The global variables are common to all contexts running the same scripts.

I'm currently looking in to some way of allowing the script writer to declare global variables as thread local, i.e. private for each context.

In the upcoming version of AngelScript you will also be able to let the scripts store structures within the application, in this way you can have the script allocate a structure, and store it for later use.

For now, you can implement application functions for storing data specific for a context, e.g:


void StoreFloat(string &name, float val)
{
asIScriptContext *ctx = asGetActiveContext();
// map the ctx pointer to an application object that can store attributes
CAttributes *attr = GetAttributesForContext(ctx);
attr->StoreFloat(name, val);
}


I also intend to change the library to allow the application to store a pointer with each context. This can be used for faster mapping between context pointer and the extra data, used by the application.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!