diff -r 71208f97d9ca -r 5e0bdf7f234f lvm.js --- a/lvm.js Fri May 28 02:21:30 2010 +0100 +++ b/lvm.js Fri May 28 02:21:54 2010 +0100 @@ -46,14 +46,22 @@ else throw "Attempt to call a " + this.type + " value"; }, - index: function (key) + index: function (key, raw) { if(this.type == "table") { - var val = this.value[key.value]; - if(typeof(val) == "undefined") - return new LValue("nil", null); - return val; + var val; + if(key.value in this.value) + return this.value[key.value]; + else if(raw != true && this.metatable && this.metatable.type != "nil") + { + var __index = this.metatable.index(new LValue("string", "__index")); + if(__index.type != "nil") + { + return LValueFromValue(__index.call([this, key])[0]); + } + } + return new LValue("nil", null); } else throw "Attempt to index a " + this.type + " value";