diff --git a/include/sqrat/sqratObject.h b/include/sqrat/sqratObject.h index b87f9a27..b4c5a539 100644 --- a/include/sqrat/sqratObject.h +++ b/include/sqrat/sqratObject.h @@ -105,6 +105,21 @@ public: sq_addref(vm, &obj); } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Constructs an Object from a Squirrel object at a certain index on the stack + /// + /// \param i Index of the Squirrel object on stack + /// \param v VM that the object will exist in + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + Object(SQInteger i, HSQUIRRELVM v = DefaultVM::Get()) : vm(v), release(true) { + if (SQ_FAILED(sq_getstackobj(vm, i, &obj))) { + sq_resetobject(&obj); + } else { + sq_addref(vm, &obj); + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Constructs an Object from a C++ instance ///