This repository has been archived on 2021-07-14. You can view files and clone it, but cannot push or open issues or pull requests.
scriptcraft/src/main/js/modules/lightning.js
2015-12-30 13:01:11 +00:00

31 lines
941 B
JavaScript

'use strict';
/************************************************************************
## Lightning module
Causes a bolt of lightning to strike.
### Usage
```javascript
// strike lightning wherever a player's arrow lands
var lightning = require('lightning');
events.projectileHit( function( event ){
if ( entities.arrow( event.projectile ) // it's an arrow
&& entities.player( event.projectile.owner ) // it was shot by a player
) {
lightning( event.projectile ); // strike lightning at the arrow location
}
});
```
***/
module.exports = function lightning( something ) {
if (__plugin.canary && something.location){
return something.location.world.makeLightningBolt(something.location);
}
if (__plugin.bukkit && something.location){
return something.location.world.strikeLightning(something.location);
}
console.log('Need an object with a location property for lightning strike');
return null;
};