Refactored luaGetValue(), my previous fix was incorrect.