Host app access to AS variables

Started by
4 comments, last by WitchLord 19 years, 7 months ago
I know it is possible to have the host application expose its variables to angelscript, but how would i expose angelscript variables to the host app?
Advertisement
The engine interface provides the following methods for accessing globally declared script variables:

	// Script global variables	virtual int GetGlobalVarCount(const char *module) = 0;	virtual int GetGlobalVarIDByIndex(const char *module, int index) = 0;	virtual int GetGlobalVarIDByName(const char *module, const char *name) = 0;	virtual int GetGlobalVarIDByDecl(const char *module, const char *decl) = 0;	virtual int GetGlobalVarDeclaration(int gvarID, char *buffer, int bufferSize) = 0;	virtual int GetGlobalVarName(int gvarID, char *buffer, int bufferSize) = 0;	virtual int GetGlobalVarPointer(int gvarID, void **pointer) = 0;


If you know the type and name of the variable you can get the id with GetGlobalVarIDByDecl() then use GetGlobalVarPointer() to get a pointer to the memory where the variable is located. If you don't know the variables or their types use the other methods for retrieving that info.

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

what if the variables are not globally declared?

And if that is not possible what kind of debugging information can be generated?
The host application doesn't have direct access to the script context stacks. It wouldn't be of much use anyway since the script doesn't store the type of the local variables on the stack.

The application can get information on where in the code the script execution is currently located at. There are functions for getting which module, function, and line that is being executed. The code can also be stepped through, line by line.

What exactly do you want to do? If you explain to me I might be able to help you. I might even be able to change AngelScript to include the feature you need if it doesn't have it already.

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

My intentions for angelscript are to be able to allow a person to write a script, and while the script is executing, have a real time display of a combination of user defined script variables and host app variables, and the display of which be designated by the user through a simple interface.
It's possible for me to give access to the stack used by a function, and even the list of functions called up until current execution point.

However, I can't give you information about what type of data is stored at each position in the stack, nor the name of the variable. This information simply isn't stored anywhere. Some positions even store more than one variable in the same functions (at different times though).

Maybe I could alter the library to store the name, type, and position of each variable used in the functions, and then allow the application to access this information. However, I'm afraid that I'll have to give this quite a low priority. If you wish to do the alteration yourself though, I might be able to include your changes in the main library code afterwards.

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