From 4b678a3e3b8d914e3758df449d7b6dd75ae64359 Mon Sep 17 00:00:00 2001 From: AtomicWalrus Date: Wed, 15 Mar 2023 00:05:01 -0600 Subject: [PATCH] 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 --- .../utility/scripts/gameObjectManagement.tscript | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript b/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript index fff2a8ace..64b75e331 100644 --- a/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript +++ b/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript @@ -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)