2017-02-08 00:15:55 +01:00
|
|
|
/*
|
|
|
|
Minetest
|
|
|
|
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2017-02-08 00:15:55 +01:00
|
|
|
|
|
|
|
#include "l_metadata.h"
|
2017-04-07 08:50:17 +02:00
|
|
|
#include "lua_api/l_base.h"
|
2022-09-26 23:03:43 +02:00
|
|
|
#include "content/mods.h"
|
2017-02-08 00:15:55 +01:00
|
|
|
|
2017-04-07 08:50:17 +02:00
|
|
|
class ModApiStorage : public ModApiBase
|
2017-02-08 00:15:55 +01:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
static int l_get_mod_storage(lua_State *L);
|
2017-04-07 08:50:17 +02:00
|
|
|
|
2017-02-08 00:15:55 +01:00
|
|
|
public:
|
|
|
|
static void Initialize(lua_State *L, int top);
|
|
|
|
};
|
|
|
|
|
2017-04-07 08:50:17 +02:00
|
|
|
class StorageRef : public MetaDataRef
|
2017-02-08 00:15:55 +01:00
|
|
|
{
|
|
|
|
private:
|
2022-11-23 23:25:34 +01:00
|
|
|
ModStorage m_object;
|
2017-02-08 00:15:55 +01:00
|
|
|
|
2017-04-08 09:28:37 +02:00
|
|
|
static const luaL_Reg methods[];
|
2017-02-08 00:15:55 +01:00
|
|
|
|
2022-09-26 23:03:43 +02:00
|
|
|
virtual IMetadata *getmeta(bool auto_create);
|
2017-02-08 00:15:55 +01:00
|
|
|
virtual void clearMeta();
|
|
|
|
|
|
|
|
public:
|
2022-11-23 23:25:34 +01:00
|
|
|
StorageRef(const std::string &mod_name, ModStorageDatabase *db): m_object(mod_name, db) {}
|
2022-09-26 23:03:43 +02:00
|
|
|
~StorageRef() = default;
|
2017-02-08 00:15:55 +01:00
|
|
|
|
|
|
|
static void Register(lua_State *L);
|
2022-11-23 23:25:34 +01:00
|
|
|
static void create(lua_State *L, const std::string &mod_name, ModStorageDatabase *db);
|
2017-02-08 00:15:55 +01:00
|
|
|
|
2022-10-04 14:31:36 +02:00
|
|
|
static const char className[];
|
2017-02-08 00:15:55 +01:00
|
|
|
};
|