| Blockland Forums > Modification Help |
| Item hit event |
| (1/5) > >> |
| Demian:
How would I make an event that activates when the brick is hit by an item? |
| micolord:
Can I ask something? What Programming Language you used to script here in BlockLand? (Yeah, I'm an out sider.) |
| lordician:
--- Quote from: micolord on December 22, 2010, 06:22:33 PM ---Can I ask something? What Programming Language you used to script here in BlockLand? (Yeah, I'm an out sider.) --- End quote --- Irrelevant and crossposting. I'll answer this in your own topic. Most of the add-ons that have an onhit event are made with this: --- Code: ---registerInputEvent(fxDTSBrick,onToolHit,"Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "Minigame Minigame"); function ToolProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal) { parent::onCollision(%this,%obj,%col,%fade,%pos,%normal); if(%col.getClassName() $= "fxDTSBrick") { $InputTarget_["Self"] = %col; $InputTarget_["Player"] = %obj.client.player; $InputTarget_["Client"] = %obj.client; if($Server::LAN) { $InputTarget_["MiniGame"] = getMiniGameFromObject(%obj.client); } else { if(getMiniGameFromObject(%col) == getMiniGameFromObject(%obj.client)) { $InputTarget_["MiniGame"] = getMiniGameFromObject(%col); } else { $InputTarget_["MiniGame"] = 0; } } %col.processInputEvent(onToolHit,%obj.client); } } --- End code --- As far as i know, it works fine. You can replace onToolHit with anything (that makes sense), like onAxeHit. Also replace ToolProjectile with the name of the item's projectile. Like AxeProjectile. |
| Demian:
--- Quote from: lordician on December 22, 2010, 07:19:59 PM ---Most of the add-ons that have an onhit event are made with this: --- Code: ---registerInputEvent(fxDTSBrick,onToolHit,"Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "Minigame Minigame"); function ToolProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal) { parent::onCollision(%this,%obj,%col,%fade,%pos,%normal); if(%col.getClassName() $= "fxDTSBrick") { $InputTarget_["Self"] = %col; $InputTarget_["Player"] = %obj.client.player; $InputTarget_["Client"] = %obj.client; if($Server::LAN) { $InputTarget_["MiniGame"] = getMiniGameFromObject(%obj.client); } else { if(getMiniGameFromObject(%col) == getMiniGameFromObject(%obj.client)) { $InputTarget_["MiniGame"] = getMiniGameFromObject(%col); } else { $InputTarget_["MiniGame"] = 0; } } %col.processInputEvent(onToolHit,%obj.client); } } --- End code --- As far as i know, it works fine. You can replace onToolHit with anything (that makes sense), like onAxeHit. Also replace ToolProjectile with the name of the item's projectile. Like AxeProjectile. --- End quote --- I see. So I do need a projectile. I'll have to look into that then. |
| lordician:
--- Quote from: Demian on December 23, 2010, 03:59:56 AM ---I see. So I do need a projectile. I'll have to look into that then. --- End quote --- How else did you want to hit the brick? Raycasts? |
| Navigation |
| Message Index |
| Next page |