Access to Global variables



Just looking at converting over from AngelScript to Chaiscript - everything is working well except for one thing. With AngelScript I can access the list of variables I have defined like so:

for ( uint i = 0; i < ( asUINT ) scriptEngine->GetGlobalPropertyCount(); i++ )
scriptEngine->GetGlobalPropertyByIndex ( i, &name, 0, &typeID );
variableName = name;

  	if ( variableName == whichVar )
  		return i;	// Found a match - return index

return -1; // Not found

Then in my ingame console, I can reference that index, and set the value of the variable directly. I can’t seem to find anyway of doing that with chaiscript. The closest I could find was ‘get_functions()’.

Is this currently possible?



Unsure of a way to get a list of defined variables. There likely is a way to do it, though… You could add them to an associative array, and then loop through each one too, but you’re probably looking for all globals.


You can use get_scripting_objects to get all visible objects from the current scope, including globals.