Hi,
I have a class, implemented in C++, that can be instantiated from AngelScript. As per AS documentation, I have a global factory function that doesn't take any parameter.
Now, I want to pass a parameter to the C++ constructor, but I don't want the script writer to have to supply it - the script doesn't know about the parameter. The reason is that I'm using AS to enable users to extend my application, and requiring them to type in this parameter is both redundant and inconvenient for them.
At the moment, I've solved this using a global variable, that I set to a certain value before executing the AS code, and then reset afterwards. The factory function reads the global variable and does "return new MyThing(globalParameter)". However, it would be much cleaner to, somehow, supply a parameter to the factory function - which in turn can supply it to the constructor - "behind the scenes". The global variable method is the only solution I can think of, so I'm asking for help.
I hope this question is reasonably clear. I've rephrased it a couple of times. If it's not clear, I'll type up some example code.
Thanks in advance!