Ejemplo n.º 1
0
bool LuaContext::do_file_if_exists(lua_State* l, const std::string& script_name)
{
	if(load_file_if_exists(l, script_name))
	{
		call_function(l, 0, 0, script_name);
		return true;
	}
	return false;
}
Ejemplo n.º 2
0
/**
 * \brief Implementation of sol.main.load_file().
 * \param l The Lua context that is calling this function.
 * \return Number of values to return to Lua.
 */
int LuaContext::main_api_load_file(lua_State *l) {

  const std::string& file_name = luaL_checkstring(l, 1);

  if (!load_file_if_exists(l, file_name)) {
    lua_pushnil(l);
  }

  return 1;
}
Ejemplo n.º 3
0
/**
* @brief A loader that makes require() able to load Lua files
* from the quest data directory or archive.
* @param l The Lua context.
* @return Number of values to return to Lua.
*/
int LuaContext::l_loader(lua_State* l)
{
	const std::string& script_name = luaL_checkstring(l, 1);
    bool exists = load_file_if_exists(l, script_name);

    if(!exists) 
	{
      std::cerr << "No quest file.\n";
    }
    return 1;
}