Crab.include() (Idea)

From 8x9craft
Jump to: navigation, search

It would allow usage of libraries, including utility libraries like vector/matrix math, etc.

// Program: vector.lib
function Vector(x, y, z) {
    this.x = x;
    this.y = y;
    this.z = z;
    this.mag = function() {
        return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
    }
}
Vector.prototype.add = function(a, b) {
    return new Vector(a.x + b.x, a.y + b.y, a.z + b.z);
}

// Program: ownerDistance
crab.include('vector.lib');
var crabPos = crab.getPos();
var ownerPos = owner.getPos();
var crabVec = new Vector(crabPos.x, crabPos.y, crabPos.z);
var ownerVec = new Vector(-ownerPos.x, -ownerPos.y, -ownerPos.z);
var diff = Vector.add(crabVec, ownerVec);
var dist = diff.mag();

See also

Navigation menu

Internal error

Jump to: navigation, search
[5dc07abdcdd58995f5386c05] 2024-03-28 17:24:38: Fatal exception of type "Error"

Navigation menu