Alright so this might be a little difficult to do. I'll try to explain what the situation is, but you might have a hard time understanding it because it heavily relies on many aspects. This is more targeted towards C++/AngelScript itself rather than Amnesia alone, but it should work in Amnesia as well.
Basically:
How can I reference a string variable within the name of a boolean constant?
I have a situation where it would really help me out if I was able to input the string name of a current caller (for instance using asEntity to reference the current entity) into the name of a pre-defined boolean variable.
Let me attempt an example of something I know works:
void RemoveAnItem(string &in asItem)
{
if(aBoolean == true) RemoveItem(asItem + "_1");
}
This would simply remove the item that is named the same as the item calling it, but with the _1 extension. If the item calling it is named "LibraryKey" then the item removed would be named "LibraryKey_1"
Here I'm adding the extension to the item name.
So far so good. But here's what I would need.
void RemoveAnItem(string &in asItem)
{
if(aBoolean + _1 == true) RemoveItem(asItem);
}
Here I'm adding the extension to the boolean, not the item name. This script won't work for obvious reasons. What I need though, is to change the questioned boolean name into something else. What is asked here is the boolean result, but I need a different boolean's result than the one originally questioned.
I think what I need has something to do with converting a boolean to a string, but the boolean name, not the result.
Let me try another example:
bool x3y3 = false;
bool x3y4 = false;
bool x3y5 = false;
if(asArea == "area_x3y3") x3y3 = true;
if(asArea == "area_x3y4") x3y4 = true;
if(asArea == "area_x3y5") x3y5 = true;
This is something that will work, but is very tedious with many booleans. What would be preferred is to make the boolean name change depending on asArea's name. Using the StringSub function here could possibly return the string from asArea ("area_x3y3") and make a new string which is just "x3y3" however I would need to convert that new string into a boolean name.
If I'm able to do that, I'm already half way. I think this is possible, I just haven't found it yet.
But even if I'm able to convert "area_x3y3" into "x3y3" and reference that as a boolean name, I'll still need to slightly modify that name before referencing it. Ultimately, I'd need to modify it into "x3y3_e" as well as _w, _n and _s (East, west, north, south). I won't mind scripting it to check again 3 more times for each direction, but I'd rather not have to manually script it to check again 400 more times for each co-ordinate and direction (by the way, the boolean is named x3y3 because it's the X=3,Y=3 co-ordinate of a grid).
If you have any sources for constant conversions and references within C++, that'd be great. It's late and I've been messing with this for a few hours, so hopefully my explanation isn't super hard to understand.
Whew.