Blockland Forums > Modification Help
Scriptgroup, Scriptobject
Brian Smithers:
--- Quote from: Greek2me on March 27, 2012, 03:46:52 PM ---I think you could do this:
%scriptGroup.save("base/test.cs");
Then do this to load it:
exec("base/test.cs");
--- End quote ---
Using this would require some special modifications but technically you wouldn't need to load bricks with this method
heedicalking:
--- Quote from: Brian Smithers on March 27, 2012, 05:47:36 PM ---Using this would require some special modifications but technically you wouldn't need to load bricks with this method
--- End quote ---
Why wouldn't you? Say I generate one chunk of terrain and save the bricks/scriptgroup. How would i manage to reload those bricks and have them fit into the scriptgroup without the non terrain stuff being messed up.
Brian Smithers:
well
nvm
i got a better chunk method
that should actually even save the bricks.
let me write
but the file would look like this
new ScriptGroup(blah)
{
blah = "vagina";
blah1 = 1337;
blah2 = 69;
new ScriptGroup()
{
testicles = true;
new fxDTSBrick()
{
yourmom = "fat";
};
new fxDTSBrick()
{
your = "stupid";
};
};
new ScriptGroup()
{
testicles = false;
new fxDTSBrick()
{
i = "hate you";
};
new fxDTSBrick()
{
die = "in a hole";
};
};
};
get it?
Brian Smithers:
--- Quote from: heedicalking on March 27, 2012, 07:16:54 PM ---without the non terrain stuff being messed up.
--- End quote ---
put the non terrain stuff in a chunk
Brian Smithers:
function chunkObject()
{
return new ScriptGroup() { class = "Chunk" };
}
function Chunk::addBrick(%this,%brick)
{
if(%brick.inChunk)
{
error("::addBrick(%this,%brick): " @ %brick @ " is in a group!");
return;
}
%brick.inChunk = true;
%this.add(%brick);
}
function Chunk::clearBricks(%this)
{
for(%i=0;%i<%this.getCount();%i++)
{
%brick = %this.getObject(%i);
if(isObject(%brick))
%brick.delete();
}
}
function Chunk::getBricks(%this)
{
for(%i=0;%i<%this.getCount();%i++)
{
if(%str $= "")
%str = %this.getObjet(%i);
else
%str = %str SPC %this.getObject(%i);
}
return %str;
}
function ChunkGroup::getBricks(%this)
{
for(%i=0;%i<%this.getCount();%i++)
{
%chunk = %this.getObject(%i);
if(%str $= "")
%str = %chunk.getBricks();
else
%str = %str SPC %chunk.getBricks();
}
return %str;
}
function newChunkGroup()
{
%chunkGroup = new ScriptGroup()
{
class = "ChunkGroup";
};
return %chunkGroup;
}
function ChunkGroup::newChunk(%this,%bricks)
{
%chunkObject = chunkObject();
for(%i=0;%i<getFieldCount(%bricks);%i++)
{
%brick = getField(%bricks,%i);
%chunkObject.addBrick(%brick);
}
return %chunkObject;
}
package chunkBricks
{
function fxDTSBrick::onAdd(%this)
{
parent::onAdd(%this);
if(%this.isChunk == true)
%this.plant();
}
};activatepackage(chunkBricks);
that should work