Luanti 5.16.0-dev
Loading...
Searching...
No Matches
s_item.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "cpp_api/s_base.h"
8#include "irr_v3d.h"
9#include <optional>
10
11struct PointedThing;
12struct ItemStack;
14class LuaItemStack;
15class ModApiItem;
16class InventoryList;
18
20: virtual public ScriptApiBase
21{
22public:
23 /*
24 * Functions with std::optional<ItemStack> are for callbacks where Lua may
25 * want to prevent the engine from modifying the inventory after it's done.
26 * This has a longer backstory where on_use may need to empty the player's
27 * inventory without the engine interfering (see issue #6546).
28 */
29
31 u16 item_OnDrop(const ItemStack &item,
32 ServerActiveObject *dropper, v3f pos);
33 bool item_OnPlace(std::optional<ItemStack> &item,
34 ServerActiveObject *placer, const PointedThing &pointed);
35 bool item_OnUse(std::optional<ItemStack> &item,
36 ServerActiveObject *user, const PointedThing &pointed);
37 bool item_OnSecondaryUse(std::optional<ItemStack> &item,
38 ServerActiveObject *user, const PointedThing &pointed);
40 const InventoryList *old_craft_grid, const InventoryLocation &craft_inv);
42 const InventoryList *old_craft_grid, const InventoryLocation &craft_inv);
43
44protected:
45 friend class LuaItemStack;
46 friend class ModApiItem;
47
48 bool getItemCallback(const char *name, const char *callbackname, const v3s16 *p = nullptr);
53 void pushPointedThing(const PointedThing &pointed, bool hitpoint = false);
54
55};
Definition inventory.h:157
Definition l_item.h:11
Definition l_item.h:156
ScriptApiBase(ScriptingType type)
Definition s_base.cpp:64
Definition s_item.h:21
bool item_OnUse(std::optional< ItemStack > &item, ServerActiveObject *user, const PointedThing &pointed)
Definition s_item.cpp:89
bool item_OnCraft(ItemStack &item, ServerActiveObject *user, const InventoryList *old_craft_grid, const InventoryLocation &craft_inv)
Definition s_item.cpp:147
void pushPointedThing(const PointedThing &pointed, bool hitpoint=false)
Definition s_item.cpp:261
friend class LuaItemStack
Definition s_item.h:45
bool getItemCallback(const char *name, const char *callbackname, const v3s16 *p=nullptr)
Definition s_item.cpp:217
bool item_OnSecondaryUse(std::optional< ItemStack > &item, ServerActiveObject *user, const PointedThing &pointed)
Definition s_item.cpp:119
bool item_CraftPredict(ItemStack &item, ServerActiveObject *user, const InventoryList *old_craft_grid, const InventoryLocation &craft_inv)
Definition s_item.cpp:179
bool item_OnPlace(std::optional< ItemStack > &item, ServerActiveObject *placer, const PointedThing &pointed)
Definition s_item.cpp:54
friend class ModApiItem
Definition s_item.h:46
u16 item_OnDrop(const ItemStack &item, ServerActiveObject *dropper, v3f pos)
Definition s_item.cpp:20
Definition serveractiveobject.h:41
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
Definition inventorymanager.h:18
Definition inventory.h:21
An active object or node which is selected by a ray on the map.
Definition pointedthing.h:22
static std::string p(std::string path)
Definition test_filesys.cpp:64