But this time I found a script that actually trigger it rather easily...
function OnInit() //run upon initialization
function OnPostInit() //run during the entity's first logic update
thisMap = this:GetMap();
--if --thisMap == GetMapManager:GetActiveMap() and
--not thisMap:GetName() == "Gui_Stuff" then
SpawnDefaultGui(); -- I am using a function in case I decide to support multiple GUIs
function OnKill() //run when removed
BigBar = GetEntityByName("power_up_bar_big_template");
YellowBar = GetEntityByName("power_up_bar_yellow_template");
PinkBar = GetEntityByName("power_up_bar_pink_template");
WhiteBar = GetEntityByName("power_up_bar_white_template");
GreenBar = GetEntityByName("power_up_bar_green_template");
GuiCover = GetEntityByName("gui_cover_template");
big_bar = BigBar:Clone(thisMap, Vector2(0, 0));
yellow_bar = YellowBar:Clone(thisMap, Vector2(0, 0));
pink_bar = PinkBar:Clone(thisMap, Vector2(0, 0));
white_bar = WhiteBar:Clone(thisMap, Vector2(0, 0));
green_bar = GreenBar:Clone(thisMap, Vector2(0, 0));
gui_cover = GuiCover:Clone(thisMap, Vector2(58, -6));
if entity then entity:SetDeleteFlag(true); end
First, the "safe_delete" is totally non-safe, because it generate a error when entity is nil "big_bar does not exist"
Anyway, it sorta worked, but as soon as I delete some object and re-loaded the script, the engine crashed...
The same crash as the mentioned "random" crash in other topic.
I realized that the engine hates when you call SetDeleteFlag(true) twice, it plainly crashes sometimes when you do that... So, there are a way to fix any of the issues I mentioned here? Including a way to allow me to "delete" stuff that is not even created yet?