51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef L_ITEM_H_
-#define L_ITEM_H_
-
-extern "C" {
-#include <lua.h>
-#include <lauxlib.h>
-}
-
-#include <vector>
-
-#include "itemdef.h"
-#include "content_sao.h"
-#include "util/pointedthing.h"
-#include "inventory.h"
+#pragma once
#include "lua_api/l_base.h"
+#include "inventory.h" // ItemStack
-class ModApiInventory;
-
-class LuaItemStack
-{
+class LuaItemStack : public ModApiBase {
private:
ItemStack m_stack;
static const char className[];
- static const luaL_reg methods[];
+ static const luaL_Reg methods[];
// Exported functions
// get_name(self) -> string
static int l_get_name(lua_State *L);
+ // set_name(self, name)
+ static int l_set_name(lua_State *L);
+
// get_count(self) -> number
static int l_get_count(lua_State *L);
+ // set_count(self, number)
+ static int l_set_count(lua_State *L);
+
// get_wear(self) -> number
static int l_get_wear(lua_State *L);
+ // set_wear(self, number)
+ static int l_set_wear(lua_State *L);
+
+ // get_meta(self) -> string
+ static int l_get_meta(lua_State *L);
+
+ // DEPRECATED
// get_metadata(self) -> string
static int l_get_metadata(lua_State *L);
+ // DEPRECATED
+ // set_metadata(self, string)
+ static int l_set_metadata(lua_State *L);
+
+ // get_description(self)
+ static int l_get_description(lua_State *L);
+
// clear(self) -> true
static int l_clear(lua_State *L);
static int l_is_known(lua_State *L);
// get_definition(self) -> table
- // Returns the item definition table from minetest.registered_items,
+ // Returns the item definition table from core.registered_items,
// or a fallback one (name="unknown")
static int l_get_definition(lua_State *L);
public:
LuaItemStack(const ItemStack &item);
- ~LuaItemStack();
+ ~LuaItemStack() = default;
const ItemStack& getItem() const;
ItemStack& getItem();
};
-class ModApiItemMod
- :virtual public ModApiBase
-{
-public:
- ModApiItemMod();
-
- bool Initialize(lua_State *L,int top);
-
+class ModApiItemMod : public ModApiBase {
+private:
static int l_register_item_raw(lua_State *L);
+ static int l_unregister_item_raw(lua_State *L);
static int l_register_alias_raw(lua_State *L);
+ static int l_get_content_id(lua_State *L);
+ static int l_get_name_from_content_id(lua_State *L);
+public:
+ static void Initialize(lua_State *L, int top);
};
-
-
-
-#endif /* L_ITEM_H_ */