Prevent double onAdd script call for GameBase objs

Adds a check to skip this the first time onNewDataBlock is called (when the object is created) to prevent double-calling onAdd
This commit is contained in:
AtomicWalrus 2023-03-15 00:05:01 -06:00
parent 4db9d241bf
commit 4b678a3e3b

View file

@ -80,10 +80,15 @@ function spawnGameObject(%name, %addToScene)
function GameBaseData::onNewDataBlock(%this, %obj)
{
if(%this.isMethod("onRemove"))
%this.onRemove(%obj);
if(%this.isMethod("onAdd"))
%this.onAdd(%obj);
if (%obj.firstDataCheck)
{
if(%this.isMethod("onRemove"))
%this.onRemove(%obj);
if(%this.isMethod("onAdd"))
%this.onAdd(%obj);
}
else
%obj.firstDataCheck = true;
}
function saveGameObject(%name, %tamlPath, %scriptPath)