diff options
Diffstat (limited to '')
-rw-r--r-- | src/script/lua_api/l_inventory.h (renamed from src/scriptapi_inventory.h) | 74 |
1 files changed, 23 insertions, 51 deletions
diff --git a/src/scriptapi_inventory.h b/src/script/lua_api/l_inventory.h index 14f4fe026..83e8039b8 100644 --- a/src/scriptapi_inventory.h +++ b/src/script/lua_api/l_inventory.h @@ -1,5 +1,5 @@ /* -Minetest-c55 +Minetest Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com> This program is free software; you can redistribute it and/or modify @@ -17,8 +17,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef LUA_INVENTORY_H_ -#define LUA_INVENTORY_H_ +#ifndef L_INVENTORY_H_ +#define L_INVENTORY_H_ extern "C" { #include <lua.h> @@ -30,6 +30,7 @@ extern "C" { #include "serverobject.h" #include "inventory.h" +#include "lua_api/l_base.h" /* InvRef */ @@ -115,51 +116,22 @@ public: static void Register(lua_State *L); }; -void inventory_get_list_to_lua(Inventory *inv, const char *name,lua_State *L); -void inventory_set_list_from_lua(Inventory *inv, const char *name, - lua_State *L, int tableindex, int forcesize=-1); - -/*****************************************************************************/ -/* Minetest interface */ -/*****************************************************************************/ -/* Detached inventory callbacks */ -// Return number of accepted items to be moved -int scriptapi_detached_inventory_allow_move(lua_State *L, - const std::string &name, - const std::string &from_list, int from_index, - const std::string &to_list, int to_index, - int count, ServerActiveObject *player); -// Return number of accepted items to be put -int scriptapi_detached_inventory_allow_put(lua_State *L, - const std::string &name, - const std::string &listname, int index, ItemStack &stack, - ServerActiveObject *player); -// Return number of accepted items to be taken -int scriptapi_detached_inventory_allow_take(lua_State *L, - const std::string &name, - const std::string &listname, int index, ItemStack &stack, - ServerActiveObject *player); -// Report moved items -void scriptapi_detached_inventory_on_move(lua_State *L, - const std::string &name, - const std::string &from_list, int from_index, - const std::string &to_list, int to_index, - int count, ServerActiveObject *player); -// Report put items -void scriptapi_detached_inventory_on_put(lua_State *L, - const std::string &name, - const std::string &listname, int index, ItemStack &stack, - ServerActiveObject *player); -// Report taken items -void scriptapi_detached_inventory_on_take(lua_State *L, - const std::string &name, - const std::string &listname, int index, ItemStack &stack, - ServerActiveObject *player); - -/*****************************************************************************/ -/* Mod API */ -/*****************************************************************************/ -int l_create_detached_inventory_raw(lua_State *L); -int l_get_inventory(lua_State *L); - -#endif /* LUA_INVENTORY_H_ */ +class ModApiInventory + : public ModApiBase +{ +public: + ModApiInventory(); + + bool Initialize(lua_State *L, int top); + + static int l_create_detached_inventory_raw(lua_State *L); + static int l_get_inventory(lua_State *L); +private: + static void inventory_set_list_from_lua(Inventory *inv, const char *name, + lua_State *L, int tableindex, int forcesize); + static void inventory_get_list_to_lua(Inventory *inv, const char *name, + lua_State *L); + +}; + +#endif /* L_INVENTORY_H_ */ |