Hi , so i can’t tell whats exacly happening but in some cases calling ScriptInstance::CrateObject crashes. I couldn’t figure out why…
The script works fine until i add another method then the game starts crashing afterwards.
if (!scriptName.Empty())
{
Urho3D::ScriptInstance * scrInst = this->CreateComponent<Urho3D::ScriptInstance>();
// Cript instance is successfully created
scrInst->CreateObject(GetSubsystem<Urho3D::ResourceCache>()->GetResource<Urho3D::ScriptFile>(scriptName + ".as") , "INFScript");
// The program never reaches this part !
}
i think that (i suppose) there’s a dangling pointer somewhere in either anglescript’s or Urho’s CreateObject function…
Here’s the latest test i ran :
This works :
[code]class INFScript : ScriptObject
{
void onPick()
{
INFGame@ game = getGame();
Node@ key = node.GetChild(“Security Key” , true);
if (key !is null) game.switchToPuzzleMode();
else game.enableDialog("The security panel is turned off.There's a keyhole on the panel" , 0 , 0 , null);
}
}[/code]
changing to this and it just keeps crashing.
[code]class INFScript : ScriptObject
{
void onPick()
{
INFGame@ game = getGame();
Node@ key = node.GetChild(“Security Key” , true);
if (key !is null) game.switchToPuzzleMode();
else game.enableDialog("The security panel is turned off.There's a keyhole on the panel" , 0 , 0 , null);
}
Overloaded function with a Node as a parameter
void onPick(Node@ inNode)
{
}
}[/code]
EDIT:
now thats strange… deleting few lines remove empty lines and now it works again…
The crash is totally unpredictable…