Luanti 5.10.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;
14struct ItemDefinition;
15class LuaItemStack;
16class ModApiItem;
17class InventoryList;
19
21: virtual public ScriptApiBase
22{
23public:
24 /*
25 * Functions with std::optional<ItemStack> are for callbacks where Lua may
26 * want to prevent the engine from modifying the inventory after it's done.
27 * This has a longer backstory where on_use may need to empty the player's
28 * inventory without the engine interfering (see issue #6546).
29 */
30
31 bool item_OnDrop(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:194
Definition l_item.h:11
Definition l_item.h:156
Definition s_base.h:64
Definition s_item.h:22
bool item_OnUse(std::optional< ItemStack > &item, ServerActiveObject *user, const PointedThing &pointed)
Definition s_item.cpp:83
bool item_OnCraft(ItemStack &item, ServerActiveObject *user, const InventoryList *old_craft_grid, const InventoryLocation &craft_inv)
Definition s_item.cpp:141
void pushPointedThing(const PointedThing &pointed, bool hitpoint=false)
Definition s_item.cpp:255
bool item_OnDrop(ItemStack &item, ServerActiveObject *dropper, v3f pos)
Definition s_item.cpp:21
bool getItemCallback(const char *name, const char *callbackname, const v3s16 *p=nullptr)
Definition s_item.cpp:211
bool item_OnSecondaryUse(std::optional< ItemStack > &item, ServerActiveObject *user, const PointedThing &pointed)
Definition s_item.cpp:113
bool item_CraftPredict(ItemStack &item, ServerActiveObject *user, const InventoryList *old_craft_grid, const InventoryLocation &craft_inv)
Definition s_item.cpp:173
bool item_OnPlace(std::optional< ItemStack > &item, ServerActiveObject *placer, const PointedThing &pointed)
Definition s_item.cpp:48
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 itemdef.h:66
Definition inventory.h:19
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:53