Cannot Instantiate new Drone() but box() works
nixnax opened this issue ยท 1 comments
Better title: Drone() parameters are NOT optional
The command /js var d = box() works:
[INFO]: Command: /js var d = box()
[INFO]: Command: /js d
But the command /js var d = new Drone() fails:
[ERROR]: javax.script.ScriptException: javax.script.ScriptException:
TypeError: Cannot read property "location" from undefined in <eval> at line number 637 in <eval>
at line number 622 at column number 8
Version Info
[INFO]: Starting: CanaryMod 1.7.10-1.1.3
[INFO]: Canary Path: /C:/Users/user/Downloads/CanaryMod-1.7.10-1.1.3.jar
Working From: C:\Users\user\Downloads
Update: This works:
// a simple module to instantiate a drone
console.log("Starting module %s", __filename);
console.log("Trying to find object drone:");
console.log(drone);
console.log("Trying to find object x:");
console.log(x);
var drone = require ('../drone/drone');
var x = new Drone(0,0,0,0,0); // ONLY WORKS IF YOU SUPPLY ALL PARAMETERS
console.log("Trying to find object drone:");
console.log(drone);
console.log("Trying to find object x:");
console.log(x);
console.log("End of module %s", __filename);
Output after js refresh():
[22:06:10] [CanaryMod] [INFO]: Disabling plugin org.scriptcraftjs.canarymod.ScriptCraftPlugin
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [WARN]: alias plugin is not yet supported in CanaryMod
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [WARN]: arrows plugin not yet supported in CanaryMod
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: js-patch setTimeout() test complete
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [WARN]: commando-test not yet supported in CanaryMod
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [WARN]: commando plugin is not yet supported in CanaryMod
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [WARN]: cow-clicker minigame is not yet supported in CanaryMod
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [WARN]: signs/menu is not yet supported in CanaryMod
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: Starting module C:/Users/user/Downloads/scriptcraft/plugins/try/try1.js
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: Trying to find object drone:
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: undefined
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: Trying to find object x:
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: undefined
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: Trying to find object drone:
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: jdk.nashorn.internal.scripts.JO4@6bb4bb7b
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: Trying to find object x:
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: jdk.nashorn.internal.scripts.JO12@40ed550a
[22:06:10] [org.scriptcraftjs.canarymod.ScriptCraftPlugin] [INFO]: End of module C:/Users/user/Downloads/scriptcraft/plugins/try/try1.js
The Drone constructor needs an object which has a Location property (e.g. a Player - try new Drone(self)
or a Location object. At the in-game prompt:
/js var d = new Drone(self)
If you want to do some building using Drone from a script you should extend it like this:
// scriptcraft/plugins/myGoldPillar.js
var Drone = require('./drone/drone.js').Drone;
var blocks = require('blocks');
function goldpillar(){
// builds a gold pillar 3 blocks high
this
.box(blocks.gold, 1, 3, 1);
}
Drone.extend( goldpillar );
// at in-game prompt type /js goldpillar()