Luanti 5.15.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
30 bool item_OnDrop(ItemStack &item,
31 ServerActiveObject *dropper, v3f pos);
32 bool item_OnPlace(std::optional<ItemStack> &item,
33 ServerActiveObject *placer, const PointedThing &pointed);
34 bool item_OnUse(std::optional<ItemStack> &item,
35 ServerActiveObject *user, const PointedThing &pointed);
36 bool item_OnSecondaryUse(std::optional<ItemStack> &item,
37 ServerActiveObject *user, const PointedThing &pointed);
39 const InventoryList *old_craft_grid, const InventoryLocation &craft_inv);
41 const InventoryList *old_craft_grid, const InventoryLocation &craft_inv);
42
43protected:
44 friend class LuaItemStack;
45 friend class ModApiItem;
46
47 bool getItemCallback(const char *name, const char *callbackname, const v3s16 *p = nullptr);
52 void pushPointedThing(const PointedThing &pointed, bool hitpoint = false);
53
54};
Definition inventory.h:157
Definition l_item.h:11
Definition l_item.h:156
Definition s_base.h:63
Definition s_item.h:21
bool item_OnUse(std::optional< ItemStack > &item, ServerActiveObject *user, const PointedThing &pointed)
Definition s_item.cpp:82
bool item_OnCraft(ItemStack &item, ServerActiveObject *user, const InventoryList *old_craft_grid, const InventoryLocation &craft_inv)
Definition s_item.cpp:140
void pushPointedThing(const PointedThing &pointed, bool hitpoint=false)
Definition s_item.cpp:254
bool item_OnDrop(ItemStack &item, ServerActiveObject *dropper, v3f pos)
Definition s_item.cpp:20
bool getItemCallback(const char *name, const char *callbackname, const v3s16 *p=nullptr)
Definition s_item.cpp:210
bool item_OnSecondaryUse(std::optional< ItemStack > &item, ServerActiveObject *user, const PointedThing &pointed)
Definition s_item.cpp:112
bool item_CraftPredict(ItemStack &item, ServerActiveObject *user, const InventoryList *old_craft_grid, const InventoryLocation &craft_inv)
Definition s_item.cpp:172
bool item_OnPlace(std::optional< ItemStack > &item, ServerActiveObject *placer, const PointedThing &pointed)
Definition s_item.cpp:47
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