103
« on: December 25, 2015, 01:31:58 PM »
function shiftBlb(%file,%shift)
{
%fname = getSubStr(%file,0,strlen(%file)-4);
%ext = getSubStr(%file,strlen(%file)-3,strlen(%file));
if(%ext !$= "blb")
return warn("File is not a brick");
%xS = getWord(%shift,0);
%yS = getWord(%shift,1);
%zS = getWord(%shift,2);
%fr = new fileObject();
%fw = new fileObject();
%fr.openForRead(%file);
%fw.openForWrite(%fname @ "_shift." @ %ext);
%nextPos = -1;
while(!%fr.isEOF())
{
if(%nextPos == 4)
%nextPos = -1;
%line = %fr.readLine();
if(%nextPos > -1)
{
%pos = %line;
%x = getWord(%pos,0);
%y = getWord(%pos,1);
%z = getWord(%pos,2);
%x += %xS;
%y += %yS;
%z += %zS;
%str = %x SPC %y SPC %z;
%fw.writeLine(%str);
%nextPos++;
continue;
}
%fw.writeLine(%line);
if(%line $= "POSITION:")
%nextPos = 0;
}
%fr.close();
%fr.delete();
%fw.close();
%fw.delete();
}
this shifts the quads on the brick by a factor of shift without affecting the collision box and outputs it to filename_shift.blb
this is very useful for repositioning bricks you are working on in-game