added new entities and spawn modules
This commit is contained in:
parent
4aa28c0af3
commit
e285bb6891
6 changed files with 70 additions and 28 deletions
|
@ -1 +1 @@
|
|||
scriptcraft-version=3.1.10
|
||||
scriptcraft-version=3.1.11
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
RELEASE NOTES
|
||||
=============
|
||||
3.1.11 Release (2015 11 21)
|
||||
---------------------------
|
||||
|
||||
Added new modules
|
||||
|
||||
* entities
|
||||
* spawn
|
||||
|
||||
And new Drone function `spawn()`
|
||||
|
||||
To use:
|
||||
Point at a block then type...
|
||||
```
|
||||
/js spawn('ZOMBIE').fwd().times(5).right().back(5).times(6)
|
||||
```
|
||||
|
||||
... unleash a horde of zombies (in 5x6 grid formation).
|
||||
|
||||
3.1.10 Release (2015 08 16)
|
||||
---------------------------
|
||||
|
|
18
src/main/js/modules/entities.js
Normal file
18
src/main/js/modules/entities.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*global __plugin, org, Packages, module, exports*/
|
||||
'use strict';
|
||||
var entities = {},
|
||||
entitytypes,
|
||||
t, i, name;
|
||||
if (__plugin.bukkit) {
|
||||
entitytypes = org.bukkit.entity.EntityType.values();
|
||||
}
|
||||
if (__plugin.canary) {
|
||||
entitytypes = Packages.net.canarymod.api.entity.EntityType.values();
|
||||
}
|
||||
for (t in entitytypes) {
|
||||
if (entitytypes[t] && entitytypes[t].ordinal) {
|
||||
name = entitytypes[t].name();
|
||||
entities[name] = entitytypes[t];
|
||||
}
|
||||
}
|
||||
module.exports = entities;
|
18
src/main/js/modules/spawn.js
Normal file
18
src/main/js/modules/spawn.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*global require, module, __plugin, Packages*/
|
||||
'use strict';
|
||||
var entities = require('entities');
|
||||
|
||||
module.exports = function(entityType, location){
|
||||
if (typeof entityType === 'string'){
|
||||
entityType = entities[entityType];
|
||||
}
|
||||
var world = location.world;
|
||||
if (__plugin.bukkit){
|
||||
world.spawnEntity( location, entityType);
|
||||
}
|
||||
if (__plugin.canary){
|
||||
var Canary = Packages.net.canarymod.Canary,
|
||||
entityInstance = Canary.factory().entityFactory.newEntity(entityType, location);
|
||||
entityInstance.spawn();
|
||||
}
|
||||
};
|
8
src/main/js/plugins/drone/contrib/spawn.js
Normal file
8
src/main/js/plugins/drone/contrib/spawn.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
var spawnFn = require('spawn'),
|
||||
Drone = require('drone')
|
||||
;
|
||||
function spawn(entityType){
|
||||
spawnFn(entityType, this.getBlock().location);
|
||||
}
|
||||
Drone.extend(spawn);
|
|
@ -21,23 +21,12 @@ or <http://docs.visualillusionsent.net/CanaryLib/1.0.0/net/canarymod/api/entity/
|
|||
for a list of possible entities (creatures) which can be spawned.
|
||||
|
||||
***/
|
||||
var entities = [],
|
||||
entityType = null,
|
||||
entitytypes,
|
||||
t;
|
||||
if (__plugin.bukkit) {
|
||||
entityType = org.bukkit.entity.EntityType;
|
||||
var entities = require('entities'),
|
||||
spawn = require('spawn');
|
||||
var entityNames = [];
|
||||
for (var name in entities){
|
||||
entityNames.push(name);
|
||||
}
|
||||
if (__plugin.canary) {
|
||||
entityType = Packages.net.canarymod.api.entity.EntityType;
|
||||
}
|
||||
entitytypes = entityType.values();
|
||||
for (t in entitytypes) {
|
||||
if (entitytypes[t] && entitytypes[t].ordinal) {
|
||||
entities.push(entitytypes[t].name());
|
||||
}
|
||||
}
|
||||
|
||||
command('spawn', function (parameters, sender) {
|
||||
if (!isOp(sender)) {
|
||||
echo(sender, 'Only operators can perform this command');
|
||||
|
@ -48,14 +37,6 @@ command('spawn', function (parameters, sender) {
|
|||
echo(sender, 'You have no location. This command only works in-game.');
|
||||
return;
|
||||
}
|
||||
var world = location.world || sender.world,
|
||||
type = ('' + parameters[0]).toUpperCase();
|
||||
if (__plugin.bukkit) {
|
||||
world.spawnEntity(location, entityType[type]);
|
||||
}
|
||||
if (__plugin.canary) {
|
||||
var Canary = Packages.net.canarymod.Canary,
|
||||
entity = Canary.factory().entityFactory.newEntity(entityType[type], location);
|
||||
entity.spawn();
|
||||
}
|
||||
}, entities);
|
||||
var name = ('' + parameters[0]).toUpperCase();
|
||||
spawn( name, sender.location);
|
||||
}, entityNames);
|
||||
|
|
Reference in a new issue