Hodo33 Posted February 27, 2019 Posted February 27, 2019 Given this instance:%obj = new Door() { dataBlock = %block; parentGroup = "MissionGroup"; };Should I include this after creation ? MissionGroup.add(%obj); If I make the parentgroup equal to MissionGroup will it get automatically deleted on zone unload ? Quote
Happenstance Posted March 1, 2019 Posted March 1, 2019 I typically add the object after it's created (MissionGroup.add()) but parentGroup looks like a shortcut that does the same thing.MissionGroup gets deleted when a mission ends and because it's a SimGroup, any objects contained within it will also be deleted. Quote
Steve_Yorkshire Posted March 4, 2019 Posted March 4, 2019 As @Happenstance missionGroup gets deleted when the server ends. If you want a parentgroup which lasts through multiple missions you can test to see if it needs creating at either missionLoad/StartGame or mainMenu::onWake(). I tend to have a check in mainMenu::onWake() and create the group if it does not already exist or empty all the objects if the group is found (eg: you're back at the mainMenu because the whole game is over, so delete all the data that you've been saving in the group which will mostly be scriptObjects)eg: function MainMenuGui::onWake(%this) { %group = masterCleanUp; if(!isObject(%group)) { %strat = new SimGroup(masterCleanUp); echo("\c4New masterCleanUp"); } else { %count = %group.getCount(); echo("\c4masterCleanUp already exists, empty it " @ %count); if(%count > 0) { while(%count != 0) { %index = %group.getObject(0); if(isObject(%index)) { //echo("deleting " @ %index SPC %index.getName()); %index.delete(); } //remember the escape %count = %group.getCount(); } echo("masterCleanUp emptied"); } } } Using that while() loop is actually a terrible way of doing this but hey :lol:edit: should just use %group.deleteAllObjects(); function MainMenuGui::onWake(%this) { %group = masterCleanUp; if(!isObject(%group)) { %strat = new SimGroup(masterCleanUp); echo("\c4New masterCleanUp"); } else { %count = %group.getCount(); echo("\c4masterCleanUp already exists, empty it " @ %count); if(%count > 0) { %group.deleteAllObjects(); echo("masterCleanUp emptied"); } } } I'm gonna go change my code now ... :oops: Quote
fLUnKnhaXYU Posted March 4, 2019 Posted March 4, 2019 What will happen in the case where you group together items in a sim set , that sets the parentGroup of the item to the name of the sim set .btw my version is 3.9 Quote
Azaezel Posted March 5, 2019 Posted March 5, 2019 (edited) simSets are lists of refs. simGroups are lists of actual objects. Kill a set, all you're doing is killing of a bunch of pointers. kill a group, everything's gone. (it's why stuff can be in multiple sets, but only one group) Edited March 5, 2019 by Azaezel Quote
Hodo33 Posted March 5, 2019 Author Posted March 5, 2019 Thanks for all the answers.@Steve I didn't realize you could get a count, now I can verify a clean delete, great idea... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.