| Blockland Forums > Modification Help |
| Brick activate? |
| (1/2) > >> |
| Eeposs:
Hi, i was wonder how to make a brick call a function when activated. |
| Greek2me:
--- Code: ---package blah { function fxDtsBrick::onActivate(%this,%player,%client) { parent::onActivate(%this,%player,%client); //do your stuff } }; activatePackage(blah); --- End code --- |
| Eeposs:
Thankys. |
| jes00:
I tried --- Code: ---function fxDtsBrick::onActivate(%this,%player,%client) { parent::onActivate(%this,%player,%client); messageclient(%client, '','\c3Test: Success!'); } --- End code --- And it sends the message when any brick is clicked not just the one brick I want. EDIT: It works now! :D --- Code: ---package testBrickActivate { function fxDTSBrick::onActivate(%obj, %player, %client, %pos, $vec) { %data = %obj.getDataBlock(); if(%data.getid() == TestBrickData.getId()) { messageclient(%client, '','\c3Test: Success!'); Parent::OnActivate(%obj, %player, %client, %pos, %vec); } } }; activatePackage(testBrickActivate); --- End code --- |
| MegaScientifical:
--- Code: ---package testBrickActivate { function fxDTSBrick::onActivate(%obj, %player, %client, %pos, %vec) { if(%obj.getDataBlock() $= "TestBrickData") { messageclient(%client, '','\c3Test: Success!'); Parent::OnActivate(%obj, %player, %client, %pos, %vec); } } }; activatePackage(testBrickActivate); --- End code --- By the way, jes, you broke the %vec at the start as "$vec," which would be bad in some cases. You also should make sure not to keep it like that, where it never activates unless it's that type of brick. |
| Navigation |
| Message Index |
| Next page |