Saving a trigger?

Author Topic: Saving a trigger?  (Read 1021 times)

K tryin to basically save my trigger doesn't work with save brick's or save map help anyone? Thank's.

Code: [Select]
datablock TriggerData(topTrigger)
{
    tickPeriodMS = 10;
};
function topTrigger::onTickTrigger(%this,%trigger)
{
}
function topTrigger::onEnterTrigger(%this,%trigger,%obj)
{
    %obj.settransform(vectoradd(%obj.getposition(),%trigger.off));
}
function top::onLeaveTrigger(%this,%trigger,%obj)
{
}
datablock fxDTSBrickData(brickteletrigData : brickSpawnPointData)
{
    brickFile = "base/data/bricks/baseplates/16x16F.blb";
    uiName = "16x16x5";
    subCategory = "Teleport trigger";
};
datablock fxDTSBrickData(brickteletrig2Data : brickSpawnPointData)
{
    brickFile = "base/data/bricks/flats/1x16F.blb";
    uiName = "16x1x5";
    subCategory = "Teleport trigger";
};
datablock fxDTSBrickData(brickteletrig3Data : brickSpawnPointData)
{
    brickFile = "base/data/bricks/flats/8x8F.blb";
    uiName = "8x8x5";
    subCategory = "Teleport trigger";
};
datablock fxDTSBrickData(brickteletrig4Data : brickSpawnPointData)
{
    brickFile = "base/data/bricks/flats/1x4F.blb";
    uiName = "1x4x5";
    subCategory = "Teleport trigger";
};
function brickteletrigData::onPlant(%this,%brick)
{
    schedule(10,0,"setteletrig",%brick,16,16);
    return Parent::onPlant(%this,%brick);
}
function brickteletrig2Data::onPlant(%this,%brick)
{
    schedule(10,0,"setteletrig",%brick,16,1);
    return Parent::onPlant(%this,%brick);
}
function brickteletrig3Data::onPlant(%this,%brick)
{
    schedule(10,0,"setteletrig",%brick,8,8);
    return Parent::onPlant(%this,%brick);
}
function brickteletrig4Data::onPlant(%this,%brick)
{
    schedule(10,0,"setteletrig",%brick,4,1);
    return Parent::onPlant(%this,%brick);
}
function setteletrig(%brick,%x,%y)
{
    if(%brick.angleID==2||%brick.angleID==0)
    {
        %t=%x;%x=%y;%y=%t;
    }
    %client=%brick.client;
    echo(%client);
    if(isobject(%client.teletrig))
    {
        %client.teletrig.off=vectorsub(%brick.getposition(),%client.teletrig.brick.getposition());
        //%brick.delete();
        messageclient(%client,"","Destination placed.");
        %brick.delete();
        %client.teletrig=0;
        return 1;
    }
    if(!isobject(%brick))return;
    %pos=%brick.getposition();
    %p = new Trigger()
    {
        datablock = topTrigger;
        position = vectorAdd(%pos,-%x/4 SPC %y/4 SPC 0.1);
        polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
        scale = %x/2 SPC %y/2 SPC 3;//"8 8 3";
        rotation = "1 0 0 0";
    };
    %brick.trigger=%p;
    %client.teletrig=%p;
    %p.brick=%brick;
    messageclient(%client,"","Please place a destination(Place same brick where you want it to teleport to).");
}

« Last Edit: May 24, 2008, 02:17:46 PM by Kunit_Yo »

You will need a custom saving script to save the co-ordinates of the destination brick for each one so you can reload them and they work. Look at any other mod that saves for a separate file to save to, or trace() the brick saving/loading functions and see how they work and add things to the file. Note that you will need clientside mods (so only people with the mod can save them correctly) and it will cause lots of console errors if you try to upload saves to non teleport-enabled servers.