Blockland Forums > Modification Help

Making a package?

Pages: << < (2/3) > >>

Wicked:


--- Code: ---Package Test
{
function fxDTSbrick::onPlant(%brick)
{
Parent::onPlant(%brick);

if(isObject(%brick))
{
MessageAll('', "Hey");
}
}
};
ActivatePackage(Test);
--- End code ---


tyler0:


--- Quote from: Wicked on July 09, 2010, 10:48:25 PM ---
--- Code: ---Package Test
{
function fxDTSbrick::onPlant(%brick)
{
Parent::onPlant(%brick);

if(isObject(%brick))
{
MessageAll('', "Hey");
}
}
};
ActivatePackage(Test);
--- End code ---

--- End quote ---

nope :(

-Jetz-:

Is your add-on active in the add-ons list?

Triple Nickels:


--- Quote from: DrenDran on July 09, 2010, 05:27:43 PM ---Take the %e out completly.
Like this:


--- Code: ---package test
{
function fxDTSbrick::Plant(%brick)
{
%e = Parent::Plant(%brick);
MessageAll('', "Hey");
}
};
activatepackage(test);

--- End code ---

--- End quote ---

Please don't post if you don't know what you're doing. This will cause the function to return "Hey" every time it is called. If you're going to take out the if statement you must do this:


--- Code: ---package test
{
function fxDTSbrick::Plant(%brick)
{
%e = Parent::Plant(%brick);
MessageAll('', "Hey");
return %e;
}
};
activatepackage(test);

--- End code ---

The reason I'm making a big deal of it is .plant(); returns a number value for the error, which many mods probably depend on. For example

if(%this.plant() == 3)
   messageClient(%client,'',"That brick's floating!");

Defaultly, if the brick was floating it would return 3, and that check would work. With your code, it would return "Hey". I don't believe "Hey" is equal to three, even if the brick was floating.

Also; Cry:

--- Quote from: Crysist on July 09, 2010, 08:56:32 PM ---Also, I think you have to return the parent. Like this

--- Code: ---package test
{
function fxDTSbrick::Plant(%brick)
{
return Parent::Plant(%brick);
MessageAll('', "Hey");
}
};
activatepackage(test);
--- End code ---

--- End quote ---
return; skips all the rest of the function, so that wouldn't work at all. You're right about returning the parent, but you'd have to put it below everything like I noted earlier.

lilboarder32:

Why not just modify fxDtsBrick::onPlant()? Is .plant() even overwritable?

Pages: << < (2/3) > >>

Go to full version