Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
c_content.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
6/******************************************************************************/
7/******************************************************************************/
8/* WARNING!!!! do NOT add this header in any include file or any code file */
9/* not being a script/modapi file!!!!!!!! */
10/******************************************************************************/
11/******************************************************************************/
12
13#pragma once
14
15extern "C" {
16#include <lua.h>
17}
18
19#include <iostream>
20#include <vector>
21#include <array>
22
24#include "util/string.h"
25#include "itemgroup.h"
26#include "itemdef.h"
27#include "util/pointabilities.h"
28#include "c_types.h"
29// We do an explicit path include because by default c_content.h include src/client/hud.h
30// prior to the src/hud.h, which is not good on server only build
31#include "../../hud.h"
32#include "content/mods.h"
33
34namespace Json { class Value; }
35
36struct MapNode;
37class NodeDefManager;
38struct PointedThing;
39struct ItemStack;
40struct ItemDefinition;
41struct ToolCapabilities;
42struct ObjectProperties;
43struct SoundSpec;
45class Inventory;
46class InventoryList;
47struct NodeBox;
48struct ContentFeatures;
49struct TileDef;
50class IGameDef;
51struct DigParams;
52struct HitParams;
53struct EnumString;
54struct NoiseParams;
55class Schematic;
58namespace treegen { struct TreeDef; }
59
60extern struct EnumString es_TileAnimationType[];
61
62
63extern const std::array<const char *, 33> object_property_keys;
64
65void read_content_features (lua_State *L, ContentFeatures &f,
66 int index);
67void push_content_features (lua_State *L,
68 const ContentFeatures &c);
69
70void push_nodebox (lua_State *L,
71 const NodeBox &box);
72void push_palette (lua_State *L,
73 const std::vector<video::SColor> *palette);
74
75TileDef read_tiledef (lua_State *L, int index,
76 u8 drawtype, bool special);
77
78void read_simplesoundspec (lua_State *L, int index,
79 SoundSpec &spec);
80NodeBox read_nodebox (lua_State *L, int index);
81
82void read_server_sound_params (lua_State *L, int index,
83 ServerPlayingSound &params);
84
85void push_dig_params (lua_State *L,
86 const DigParams &params);
87void push_hit_params (lua_State *L,
88 const HitParams &params);
89
90ItemStack read_item (lua_State *L, int index, IItemDefManager *idef);
91
92struct TileAnimationParams read_animation_definition(lua_State *L, int index);
93
94PointabilityType read_pointability_type (lua_State *L, int index);
95Pointabilities read_pointabilities (lua_State *L, int index);
96void push_pointability_type (lua_State *L, PointabilityType pointable);
97void push_pointabilities (lua_State *L, const Pointabilities &pointabilities);
98
100void push_tool_capabilities (lua_State *L,
101 const ToolCapabilities &prop);
102WearBarParams read_wear_bar_params (lua_State *L, int table);
103void push_wear_bar_params (lua_State *L,
104 const WearBarParams &prop);
105
106void read_item_definition (lua_State *L, int index, const ItemDefinition &default_def,
107 ItemDefinition &def);
108void push_item_definition (lua_State *L,
109 const ItemDefinition &i);
110void push_item_definition_full (lua_State *L,
111 const ItemDefinition &i);
112
113void read_object_properties (lua_State *L, int index,
115 ObjectProperties *prop,
116 IItemDefManager *idef);
117
118void push_object_properties (lua_State *L,
119 const ObjectProperties *prop);
120
121void push_inventory_list (lua_State *L,
122 const InventoryList &invlist);
123void push_inventory_lists (lua_State *L,
124 const Inventory &inv);
125void read_inventory_list (lua_State *L, int tableindex,
126 Inventory *inv, const char *name,
127 IGameDef *gdef, int forcesize=-1);
128
129MapNode readnode (lua_State *L, int index);
130void pushnode (lua_State *L, const MapNode &n);
131
132
133void read_groups (lua_State *L, int index,
134 ItemGroupList &result);
135
136void push_groups (lua_State *L,
137 const ItemGroupList &groups);
138
139//TODO rename to "read_enum_field"
140int getenumfield (lua_State *L, int table,
141 const char *fieldname,
142 const EnumString *spec,
143 int default_);
144
145bool getflagsfield (lua_State *L, int table,
146 const char *fieldname,
147 FlagDesc *flagdesc,
148 u32 *flags, u32 *flagmask);
149
150bool read_flags (lua_State *L, int index,
151 FlagDesc *flagdesc,
152 u32 *flags, u32 *flagmask);
153
154void push_flags_string (lua_State *L, FlagDesc *flagdesc,
155 u32 flags, u32 flagmask);
156
157u32 read_flags_table (lua_State *L, int table,
158 FlagDesc *flagdesc, u32 *flagmask);
159
160void push_items (lua_State *L,
161 const std::vector<ItemStack> &items);
162
163std::vector<ItemStack> read_items (lua_State *L,
164 int index,
165 IGameDef* gdef);
166
167void push_simplesoundspec (lua_State *L,
168 const SoundSpec &spec);
169
170bool string_to_enum (const EnumString *spec,
171 int &result,
172 const std::string &str);
173
174bool read_noiseparams (lua_State *L, int index,
175 NoiseParams *np);
176void push_noiseparams (lua_State *L, NoiseParams *np);
177
178bool read_tree_def (lua_State *L, int idx,
179 const NodeDefManager *ndef,
180 treegen::TreeDef &tree_def);
181
182void luaentity_get (lua_State *L,u16 id);
183
184bool push_json_value (lua_State *L,
185 const Json::Value &value,
186 int nullindex);
187void read_json_value (lua_State *L, Json::Value &root,
188 int index, u16 max_depth);
189
195void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm =
196 false, bool hitpoint = false);
197
198void push_objectRef (lua_State *L, const u16 id);
199
200void read_hud_element (lua_State *L, HudElement *elem);
201
202void push_hud_element (lua_State *L, HudElement *elem);
203
204bool read_hud_change (lua_State *L, HudElementStat &stat, HudElement *elem, void **value);
205
206void push_collision_move_result(lua_State *L, const collisionMoveResult &res);
207
208void push_mod_spec(lua_State *L, const ModSpec &spec, bool include_unsatisfied);
void push_object_properties(lua_State *L, const ObjectProperties *prop)
Definition c_content.cpp:457
void push_simplesoundspec(lua_State *L, const SoundSpec &spec)
Definition c_content.cpp:1214
bool read_noiseparams(lua_State *L, int index, NoiseParams *np)
Definition c_content.cpp:1958
NodeBox read_nodebox(lua_State *L, int index)
Definition c_content.cpp:1228
void push_item_definition_full(lua_State *L, const ItemDefinition &i)
Definition c_content.cpp:176
void push_content_features(lua_State *L, const ContentFeatures &c)
Definition c_content.cpp:956
int getenumfield(lua_State *L, int table, const char *fieldname, const EnumString *spec, int default_)
Definition c_content.cpp:1319
struct TileAnimationParams read_animation_definition(lua_State *L, int index)
Definition c_content.cpp:1521
struct EnumString es_TileAnimationType[]
Definition c_content.cpp:27
void push_objectRef(lua_State *L, const u16 id)
Definition c_content.cpp:2217
void read_content_features(lua_State *L, ContentFeatures &f, int index)
Definition c_content.cpp:630
void push_items(lua_State *L, const std::vector< ItemStack > &items)
Definition c_content.cpp:1912
bool read_flags(lua_State *L, int index, FlagDesc *flagdesc, u32 *flags, u32 *flagmask)
Definition c_content.cpp:1827
void push_inventory_lists(lua_State *L, const Inventory &inv)
Definition c_content.cpp:1477
ToolCapabilities read_tool_capabilities(lua_State *L, int table)
Definition c_content.cpp:1556
void push_noiseparams(lua_State *L, NoiseParams *np)
Definition c_content.cpp:1986
void read_inventory_list(lua_State *L, int tableindex, Inventory *inv, const char *name, IGameDef *gdef, int forcesize=-1)
Definition c_content.cpp:1490
const std::array< const char *, 33 > object_property_keys
Definition c_content.cpp:246
TileDef read_tiledef(lua_State *L, int index, u8 drawtype, bool special)
Definition c_content.cpp:557
bool read_tree_def(lua_State *L, int idx, const NodeDefManager *ndef, treegen::TreeDef &tree_def)
Definition c_content.cpp:2005
void push_pointabilities(lua_State *L, const Pointabilities &pointabilities)
Definition c_content.cpp:1714
void push_palette(lua_State *L, const std::vector< video::SColor > *palette)
Definition c_content.cpp:1142
Pointabilities read_pointabilities(lua_State *L, int index)
Definition c_content.cpp:1647
void push_pointability_type(lua_State *L, PointabilityType pointable)
Definition c_content.cpp:1697
void read_groups(lua_State *L, int index, ItemGroupList &result)
Definition c_content.cpp:1878
void read_hud_element(lua_State *L, HudElement *elem)
Definition c_content.cpp:2231
void luaentity_get(lua_State *L, u16 id)
Definition c_content.cpp:1945
std::vector< ItemStack > read_items(lua_State *L, int index, IGameDef *gdef)
Definition c_content.cpp:1922
void push_flags_string(lua_State *L, FlagDesc *flagdesc, u32 flags, u32 flagmask)
Definition c_content.cpp:1867
void read_object_properties(lua_State *L, int index, ServerActiveObject *sao, ObjectProperties *prop, IItemDefManager *idef)
Definition c_content.cpp:283
void push_hit_params(lua_State *L, const HitParams &params)
Definition c_content.cpp:1806
void push_hud_element(lua_State *L, HudElement *elem)
Definition c_content.cpp:2312
PointabilityType read_pointability_type(lua_State *L, int index)
Definition c_content.cpp:1630
void push_nodebox(lua_State *L, const NodeBox &box)
Definition c_content.cpp:1090
void pushnode(lua_State *L, const MapNode &n)
Definition c_content.cpp:1293
void push_dig_params(lua_State *L, const DigParams &params)
Definition c_content.cpp:1797
void read_server_sound_params(lua_State *L, int index, ServerPlayingSound &params)
Definition c_content.cpp:1156
void read_simplesoundspec(lua_State *L, int index, SoundSpec &spec)
Definition c_content.cpp:1197
void push_tool_capabilities(lua_State *L, const ToolCapabilities &prop)
Definition c_content.cpp:1411
void push_wear_bar_params(lua_State *L, const WearBarParams &prop)
Definition c_content.cpp:1455
void push_item_definition(lua_State *L, const ItemDefinition &i)
Definition c_content.cpp:167
ItemStack read_item(lua_State *L, int index, IItemDefManager *idef)
Definition c_content.cpp:1344
u32 read_flags_table(lua_State *L, int table, FlagDesc *flagdesc, u32 *flagmask)
Definition c_content.cpp:1842
WearBarParams read_wear_bar_params(lua_State *L, int table)
Definition c_content.cpp:1749
bool string_to_enum(const EnumString *spec, int &result, const std::string &str)
Definition c_content.cpp:1329
bool push_json_value(lua_State *L, const Json::Value &value, int nullindex)
Definition c_content.cpp:2113
void read_item_definition(lua_State *L, int index, const ItemDefinition &default_def, ItemDefinition &def)
Definition c_content.cpp:36
bool read_hud_change(lua_State *L, HudElementStat &stat, HudElement *elem, void **value)
Definition c_content.cpp:2374
void push_inventory_list(lua_State *L, const InventoryList &invlist)
Definition c_content.cpp:1471
void push_groups(lua_State *L, const ItemGroupList &groups)
Definition c_content.cpp:1902
void push_collision_move_result(lua_State *L, const collisionMoveResult &res)
Definition c_content.cpp:2469
void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm=false, bool hitpoint=false)
Definition c_content.cpp:2181
void read_json_value(lua_State *L, Json::Value &root, int index, u16 max_depth)
Definition c_content.cpp:2129
bool getflagsfield(lua_State *L, int table, const char *fieldname, FlagDesc *flagdesc, u32 *flags, u32 *flagmask)
Definition c_content.cpp:1815
void push_mod_spec(lua_State *L, const ModSpec &spec, bool include_unsatisfied)
Definition c_content.cpp:2535
MapNode readnode(lua_State *L, int index)
Definition c_content.cpp:1279
Definition gamedef.h:36
Definition itemdef.h:129
Definition inventory.h:194
Definition inventory.h:314
This class is for getting the actual properties of nodes from their content ID.
Definition nodedef.h:540
Definition mg_schematic.h:79
Definition serveractiveobject.h:41
HudElementStat
Definition hud.h:59
std::unordered_map< std::string, int > ItemGroupList
Definition itemgroup.h:10
static const struct table_key table[]
Definition keycode.cpp:33
Definition c_content.h:34
Definition mg_decoration.h:19
#define idx(x, y)
Definition noise.cpp:490
PointabilityType
Definition pointabilities.h:13
Definition nodedef.h:294
Definition tool.h:109
Definition c_types.h:16
Definition string.h:67
Definition tool.h:131
Definition hud.h:84
Definition itemdef.h:66
Definition inventory.h:19
Definition mapnode.h:124
Definition mods.h:25
Definition nodedef.h:112
Definition noise.h:119
Definition object_properties.h:15
Definition pointabilities.h:30
An active object or node which is selected by a ray on the map.
Definition pointedthing.h:22
Definition server.h:109
Describes the sound information for playback.
Definition sound.h:20
Definition tileanimation.h:18
Definition nodedef.h:263
Definition tool.h:46
Definition tool.h:78
Definition collision.h:43
Definition treegen.h:25