Blockland Forums > Modification Help

Script Won't Change Brick

Pages: (1/3) > >>

Marcem:

I'm trying to get a brick to change states when activated, but when I try it ingame, the brick won't switch, but it makes a sound.


--- Code: ---datablock fxDTSBrickData(mugfulldata)
{
brickFile = "./mugfull.blb";
category = "special";
subCategory = "misc";
uiName = "Coffee Mug";
iconName = "Add-Ons/Brick_MarcemOddsEnds/mug";
};

datablock fxDTSBrickData(mugemptydata)
{
brickFile = "./mugempty.blb";
category = "";
subCategory = "";
uiName = "Coffee Mug";
iconName = "";
};

function drinkCoffee(%obj)
{
        %obj.setDataBlock("mugemptydata");
}

function fillCoffee(%obj)
{
%obj.setDataBlock("mugfulldata");
}
package coffeeDrink
{   
   function fxDTSBrick::OnActivate(%obj, %player, %client, %pos, %vec)
     {
       if(%obj.getDataBlock().getName() $= "mugfullData")
            drinkCoffee(%obj);
       if(%obj.getDataBlock().getName() $= "mugemptyData")
            fillCoffee(%obj);
       parent::OnActivate(%obj, %player, %client, %pos, %vec);
     }
};
activatePackage(coffeeDrink);
--- End code ---

What exactly am I doing wrong here?

Greek2me:

There needs to be a semicolon  (this thing ; ) at the end of parent::OnActivate(%obj, %player, %client, %pos, %vec)

Always look one line above the error if you don't see anything in the line it says.

Marcem:

Oh!  Thanks, never noticed that.
Now I'm having an issue with the actual brick not changing when activated.

Greek2me:

Did you look at the default treasure chest brick to see how to do it?

Marcem:

I was going off of the pumpkin brick

Pages: (1/3) > >>

Go to full version