Author Topic: [Sorta Solved] Clearing a ScriptObject's tagged fields  (Read 966 times)

How would I go about doing this?
« Last Edit: February 01, 2014, 02:35:25 PM by Electrk. »

If dump doesn't show anything of interest, would creating a new object by the same name, with all the fields you need defined on it work?
Just delete the old one when you're done

If dump doesn't show anything of interest, would creating a new object by the same name, with all the fields you need defined on it work?
Just delete the old one when you're done

I want to recycle as much as I can
I don't want to be creating and deleting a bunch of objects

What are you trying to do with this...?

I'm rewriting this and I'm using ScriptObjects for teams
Is that a bad idea?

I feel like simsets would be a better choice for this. Creation of both of these is pretty efficient though, I don't think you have to worry about recycling

I'd try going simset, but I'm not sure if you can add a className to those so you can define methods. If you can, definitely - I can't see any other reason they wouldn't be used for the default minigames. If not, you can just set the size of your list of members to zero. When you then go to add members in, you'll overwrite the old ones, and the leftovers will just be ignored because the size says the list ends there.

This might answer your question:

Code: [Select]
function AiConnection::recycle(%this)
{
if(isObject(%this.minigame))
%this.minigame.removeMember(%this);

if(isObject(%this.camera))
%this.camera.delete();
if(isObject(%this.player))
%this.player.delete();
if(isObject(%this.tempBrick))
%this.tempBrick.delete();
if(isObject(%this.brickGroup) && %this.brickGroup.client == %this)
%this.brickGroup.client = -1;

%index = 0;
while((%field = %this.getTaggedField(%index)) !$= "")
{
//some fields cannot be changed once set.... Thanks, Badspot.
if(%lastField $= %field)
{
%index ++;
continue;
}
%lastField = %field;
%field = getField(%field,0);

//Prevent people from breaking things
if(%field !$= stripChars(%field," `~!@#$%^&*()-=+[{]}\\|;:\'\",<.>/?"))
{
error("ERROR (AiConnection::recycle): Invalid field! Skipping...");
%index ++;
continue;
}

eval(%this @ "." @ %field SPC "= \"\";");
}

if(!isObject(aiRecycler))
{
new SimSet(aiRecycler);
missionCleanup.add(aiRecycler);
}

aiRecycler.add(%this);
}

Why do you need to remove tagged fields? What exactly is the case you're doing that in?