]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/lua_api/l_inventoryaction.h
Fix and run the Lint autocorrect script
[dragonfireclient.git] / src / script / lua_api / l_inventoryaction.h
1 /*
2 Dragonfire
3 Copyright (C) 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "inventorymanager.h"
21 #include "lua_api/l_base.h"
22
23 #define GET_MOVE_ACTION                                                                  \
24         LuaInventoryAction *o = checkobject(L, 1);                                       \
25         if (o->m_action->getType() == IAction::Craft)                                    \
26                 return 0;                                                                \
27         MoveAction *act = dynamic_cast<MoveAction *>(o->m_action);
28
29 class LuaInventoryAction : public ModApiBase
30 {
31 private:
32         InventoryAction *m_action;
33
34         static void readFullInventoryLocationInto(lua_State *L, InventoryLocation *loc,
35                         std::string *list, s16 *index);
36
37         static const char className[];
38         static const luaL_Reg methods[];
39
40         // Exported functions
41
42         // garbage collector
43         static int gc_object(lua_State *L);
44
45         // __tostring metamethod
46         static int mt_tostring(lua_State *L);
47
48         // apply(self)
49         static int l_apply(lua_State *L);
50
51         // from(self, location, list, index)
52         static int l_from(lua_State *L);
53
54         // to(self, location, list, index)
55         static int l_to(lua_State *L);
56
57         // craft(self, location)
58         static int l_craft(lua_State *L);
59
60         // set_count(self, count)
61         static int l_set_count(lua_State *L);
62
63 public:
64         LuaInventoryAction(const IAction &type);
65         ~LuaInventoryAction();
66
67         // LuaInventoryAction(inventory action type)
68         // Creates an LuaInventoryAction and leaves it on top of stack
69         static int create_object(lua_State *L);
70         // Not callable from Lua
71         static int create(lua_State *L, const IAction &type);
72         static LuaInventoryAction *checkobject(lua_State *L, int narg);
73         static void Register(lua_State *L);
74 };