function loadEvents(%client,%file)
{
%oldbrick = %client.wrenchbrick;
%f = new fileobject();
%f.openForRead(%file);
%count = 0;
%typecount = 0;
for(%i=0;(%line=%f.readLine()) !$= "";%i++)
{
if(%line $= ""){continue;}
%p = getWord(%line,0); //firstWord doesn't take into account TAB
initContainerBoxSearch(strReplace(%p,"_"," "),"0.1 0.1 0.1",$TypeMasks::FXBrickObjectType);
%obj = containerSearchNext();
if(!%type[%p]){%type[%p] = 1;%typecount++;}
if(!isObject(%obj) || %obj.isDead() || !%obj.isPlanted){continue;}
if(!%found[%p]){%found[%p] = 1;%count++;}
%client.wrenchbrick = %obj;
if(getWord(%line,1) $= "CLEAR")
{
servercmdClearWrenchEvents(%client);
}
else if(getWord(%line,1) $= "MISC")
{
servercmdWrenchEvGroup(%client,strReplace(getWord(%line,2),"_"," "),getWord(%line,3));
}
else
{
//%client,%type,%length,%group,%e0,%e1,%e2,%e3,%e4
if(getWord(%line,2) !$= "")
{
servercmdWrenchEventAdd(%client,
strReplace(getWord(%line,2),"_"," "),
strReplace(getWord(%line,3),"_"," "),
strReplace(getWord(%line,4),"_"," "),
strReplace(getWord(%line,5),"_"," "),
strReplace(getWord(%line,6),"_"," "),
strReplace(getWord(%line,7),"_"," "),
strReplace(getWord(%line,8),"_"," "),
strReplace(getWord(%line,9),"_"," "),
strReplace(getWord(%line,10),"_"," "));
}
}
}
%f.close();
%f.delete();
messageall('MsgProcessComplete',"\c0" @ %count @ " / " @ %typecount @ " bricks loaded successfully.");
%client.wrenchbrick = %oldbrick;
}
This method is probably very slow as it does a container search for every single loading line.
What you could try to do is a clientside hack of the save file to add your parts in the saving procedure (e.g. "+-LEVEL 3" in accordance with the others) and then use $LastLoadedBrick during the loading procedure. As nobody but you would be saving the levels of bricks, this method would work.