From 60a0dc4890afc3783474eb92c303e0b22c1ac270 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 14 Jun 2011 15:50:43 +0200 Subject: Make lua resource manager automatically initialize lua state if needed --- src/FbTk/LResource.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc index 2e2a7c7..b91f0d8 100644 --- a/src/FbTk/LResource.cc +++ b/src/FbTk/LResource.cc @@ -104,6 +104,11 @@ LResourceManager::LResourceManager(const std::string &root, lua::state &l) lua::stack_sentry s(l); l.getfield(lua::REGISTRYINDEX, make_root); + if(l.isnil(-1)) { + l.pop(); + initState(l); + l.getfield(lua::REGISTRYINDEX, make_root); + } l.pushstring(root); l.call(1, 0); } -- cgit v0.11.2