mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 13:26:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
	
		
			798 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
	
		
			798 B
		
	
	
	
		
			C++
		
	
	
	
	
	
#include "content.hpp"
 | 
						|
 | 
						|
namespace LuaUi
 | 
						|
{
 | 
						|
    sol::protected_function loadContentConstructor(LuaUtil::LuaState* state)
 | 
						|
    {
 | 
						|
        sol::function loader = state->loadInternalLib("content");
 | 
						|
        sol::set_environment(state->newInternalLibEnvironment(), loader);
 | 
						|
        sol::table metatable = loader().get<sol::table>();
 | 
						|
        if (metatable["new"].get_type() != sol::type::function)
 | 
						|
            throw std::logic_error("Expected function");
 | 
						|
        return metatable["new"].get<sol::protected_function>();
 | 
						|
    }
 | 
						|
 | 
						|
    bool isValidContent(const sol::object& object)
 | 
						|
    {
 | 
						|
        if (object.get_type() != sol::type::table)
 | 
						|
            return false;
 | 
						|
        sol::table table = object;
 | 
						|
        return table.traverse_get<sol::optional<bool>>(sol::metatable_key, "__Content").value_or(false);
 | 
						|
    }
 | 
						|
}
 |