Thanks for advice. I'll try something out very soon.
By the way, can someone give me advice about how to make this stuff better?
So, I load components from scripts like this:
void AIComponent::loadFromScript(const std::string& entityName, const LuaRefWrapper& componentTable,
bool overwrite)
{
scriptManager.getData(viewSize, "viewSize", componentTable, overwrite);
scriptManager.getData(type, "type", componentTable, overwrite);
...
}
So, the first argument is the variable in which the value from the script is written. The second argument is the name of the value in the script, the third argument is the component table in the script and the fourth argument is the script manager mode (doesn't really matter that much, it's just a bool).
So, for example I have something like this in the script:
enemy = {
AIComponent = {
type = "chaser",
...
}
}
So, the componentTable is enemy.AIComponent
As you can see, always passing the third and the fourth argument is getting pretty annoying. Is the some good way to make this code better? Something like this:
void AIComponent::loadFromScript(const std::string& entityName, const LuaRefWrapper& componentTable,
bool overwrite)
{
... // temporally set componentTable and overwrite mode in ScriptManager
scriptManager.getData(viewSize, "viewSize");
scriptManager.getData(type, "type");
... // automatically unset this, so the next time I use scriptManager, it works as usual
}