#include "luastack.hpp"

LuaDefine(vec, "(x, y, z)",
    "|Create a vector."
    "|"
    "|The function 'vec' is shorthand for vector.create."
    "|") {
    LuaRet result;
    LuaArg lx, ly, lz;
    LuaVar vclass;
    LuaDefStack LS(L, result, lx, ly, lz, vclass);
    double x = LS.cknumber(lx);
    double y = LS.cknumber(ly);
    double z = LS.cknumber(lz);
    LS.createtable(result, 3, 0);
    LS.rawset(result, 1, x);
    LS.rawset(result, 2, y);
    LS.rawset(result, 3, z);
    LS.getclass(vclass, "vector");
    LS.setmetatable(result, vclass);
    return LS.result();
}

LuaDefine(vector_create, "(x, y, z)",
    "|Create a vector."
    "|") {
    LuaRet result;
    LuaArg lx, ly, lz;
    LuaVar vclass;
    LuaDefStack LS(L, result, lx, ly, lz, vclass);
    double x = LS.cknumber(lx);
    double y = LS.cknumber(ly);
    double z = LS.cknumber(lz);
    LS.createtable(result, 3, 0);
    LS.rawset(result, 1, x);
    LS.rawset(result, 2, y);
    LS.rawset(result, 3, z);
    LS.getclass(vclass, "vector");
    LS.setmetatable(result, vclass);
    return LS.result();
}
