Skip to content

scriptcraft v2.1.0-2014-08-23 generated an exception #158

@Rob-bb

Description

@Rob-bb

Hi

I am getting this error while trying to chain functions together using the callback from utils.foreach. I have pasted the two js files I am using after this error. The error happens about line 36 in the first file, jsut after the line of

console.log("2...");

[Server thread/WARN]: [scriptcraft] Task #6029585 for scriptcraft v2.1.0-2014-08-23 generated an exception
java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy33.run(Unknown Source) ~[?:?]
at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java:71) ~[CraftTask.class:git-Cauldron-MCPC-Plus-1.7.10-1.1207.01.195]
at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:346) [CraftScheduler.class:git-Cauldron-MCPC-Plus-1.7.10-1.1207.01.195]
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:862) [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:423) [lt.class:?]
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:798) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:658) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_67]
Caused by: java.security.PrivilegedActionException
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_67]
at com.sun.script.util.InterfaceImplementor$InterfaceImplementorInvocationHandler.invoke(InterfaceImplementor.java:67) ~[?:1.7.0_67]
... 8 more
Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "self" is not defined. (#740) in at line number 740
at com.sun.script.javascript.RhinoScriptEngine.invoke(RhinoScriptEngine.java:300) ~[?:1.7.0_67]
at com.sun.script.javascript.RhinoScriptEngine.invokeMethod(RhinoScriptEngine.java:266) ~[?:1.7.0_67]
at com.sun.script.util.InterfaceImplementor$InterfaceImplementorInvocationHandler$1.run(InterfaceImplementor.java:72) ~[?:1.7.0_67]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_67]
at com.sun.script.util.InterfaceImplementor$InterfaceImplementorInvocationHandler.invoke(InterfaceImplementor.java:67) ~[?:1.7.0_67]
... 8 more
Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "self" is not defined. (#740)
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3770) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3748) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.ScriptRuntime.notFoundError(ScriptRuntime.java:3833) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1826) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.ScriptRuntime.name(ScriptRuntime.java:1765) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Interpreter.java:1785) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.Interpreter.interpret(Interpreter.java:849) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:162) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(ContextFactory.java:430) ~[?:1.7.0_67]
at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116) ~[?:1.7.0_67]
at com.sun.script.javascript.RhinoScriptEngine$1.access$200(RhinoScriptEngine.java:71) ~[?:1.7.0_67]
at com.sun.script.javascript.RhinoScriptEngine$1$1.run(RhinoScriptEngine.java:105) ~[?:1.7.0_67]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_67]
at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:103) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(ScriptRuntime.java:3160) ~[?:1.7.0_67]
at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:160) ~[?:1.7.0_67]
at com.sun.script.javascript.RhinoScriptEngine.invoke(RhinoScriptEngine.java:294) ~[?:1.7.0_67]
at com.sun.script.javascript.RhinoScriptEngine.invokeMethod(RhinoScriptEngine.java:266) ~[?:1.7.0_67]
at com.sun.script.util.InterfaceImplementor$InterfaceImplementorInvocationHandler$1.run(InterfaceImplementor.java:72) ~[?:1.7.0_67]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_67]
at com.sun.script.util.InterfaceImplementor$InterfaceImplementorInvocationHandler.invoke(InterfaceImplementor.java:67) ~[?:1.7.0_67]
... 8 more

These are the two files I am using,

//
//  Functions to create a creeper face grinder
//  


var utils = require('utils');
var blocks = require('blocks');
var Drone = require('../drone/drone').Drone;
var drone;


// 98:1 is mossy stone brick, the main block for the grinder.
var m_blk = "98:1"; 

function build_grinder(){
    //  This is a huge structure.  Each pixel in the face
    //  is 10x10 blocks in the world.
    drone = new Drone(this.location);

    drone.up(3);
    drone.chkpt('grinder_start_pos');
    // clear the air
    big_box(drone.location, 0, 100, 100, 100, face);


}
Drone.extend( build_grinder );


var face = function(){
    console.log("building the front wall...");
    drone.chkpt('face_start_pos');
    console.log("1...");
    drone.left(2).down(2).back(2);
    console.log("2...");
    big_box(drone.location, m_blk, 104, 104, 3, left);  // Border for the face
    console.log("3...");
    drone.move('face_start_pos');
    console.log("4...");
};
var left = function(){  
    console.log("building the left wall...");
    drone.fwd(99).turn(1);
    drone.chkpt('left_start_pos');
    drone.left(2).down(2).back(2);
    big_box(drone.location, m_blk, 104, 104, 3, back);  // Border for the box
    drone.move('left_start_pos');
};
var back = function(){
    console.log("building the back wall...");
    drone.fwd(99).turn(1);
    drone.chkpt('back_start_pos');
    drone.left(2).down(2).back(2);
    big_box(drone.location,  m_blk, 104, 104, 3, right);  // Border for the box
    drone.move('back_start_pos');
};
var right = function(){
    console.log("building the right wall...");
    drone.fwd(99).turn(1);
    drone.chkpt('right_start_pos');
    drone.left(2).down(2).back(2);
    big_box(drone.location,  m_blk, 104, 104, 3, rf);  // Border for the box
    drone.move('right_start_pos');
};
var rf = function(){
    console.log("removing blocks...");
    drone.move('face_start_pos').back(2);
    big_box(drone.location, 0, 100, 100, 2, rl);
};
var rl = function(){
    console.log("removing blocks...");
    drone.move('left_start_pos').back(2);
    big_box(drone.location, 0, 100, 100, 2, rb);    
};
var rb = function(){
    console.log("removing blocks...");
    drone.move('back_start_pos').back(2);
    big_box(drone.location, 0, 100, 100, 2, rr);    
};
var rr = function(){
    console.log("removing blocks...");
    drone.move('right_start_pos').back(2);
    big_box(drone.location, 0, 100, 100, 2, bfloor);
};  
var bfloor = function(){
    console.log("building bottom floor...");
    drone.move('face_start_pos')
    big_box(drone.location, m_blk, 100, 1, 100, roof);  // bottom floor
};
var roof = function(){
    console.log("building roof...");
    drone.move('face_start_pos').up(99);
    big_box(drone.location, m_blk, 100, 1, 100);  // roof   
};




//
//  Nicely draw big boxes
//  without stressing  the client or server 
//  too much.
//  


var utils = require('utils');
var blocks = require('blocks');
var Drone = require('../drone/drone').Drone;

var delay = 3;
var on_done = function(){ 
     console.log("Finished building the big box.");
};

function box_width(location, block, width, height, depth, callback){
    //
    var a = [];
    a.length = width;
    var drone = new Drone(location);
    var process_width = function(item, index, object, array) {
        drone.box(block, 1, height, depth);
        drone.right(1);
    };  
    utils.foreach (a, process_width, null, delay, callback);
};

function box_height(location, block, width, height, depth, callback){
    //
    var a = [];
    a.length = height;
    var drone = new Drone(location);
    var process_height = function(item, index, object, array) {
        drone.box(block, width, 1, depth);
        drone.up(1);
    };  
    utils.foreach (a, process_height, null, delay, callback);
};

function box_depth(location, block, width, height, depth, callback){
    //
    var a = [];
    a.length = depth;
    var drone = new Drone(location);
    var process_depth = function(item, index, object, array) {
        drone.box(block, width, height, 1);
        drone.fwd(1);
    };  
    utils.foreach (a, process_width, null, delay, callback);
};

function big_box(location, block, width, height, depth, callback){
    if (typeof callback === "undefined") {
        callback = on_done;
    }
    var largest = Math.max(width, height, depth);
    console.log("Building a big box in " + largest.toString() + " steps...");
    if (width == largest) {
        box_width(location, block, width, height, depth, callback);
    }   else if (height == largest) {
        box_height(location, block, width, height, depth, callback);
    }   else if (depth == largest) {
        box_depth(location, block, width, height, depth, callback);
    }
}
Drone.extend( big_box );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions