2013-05-25 00:51:02 +02:00
|
|
|
/*
|
|
|
|
Minetest
|
|
|
|
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
/* WARNING!!!! do NOT add this header in any include file or any code file */
|
|
|
|
/* not being a script/modapi file!!!!!!!! */
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2013-05-25 00:51:02 +02:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <lua.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "irrlichttypes_bloated.h"
|
|
|
|
#include "util/string.h"
|
2016-10-05 09:03:55 +02:00
|
|
|
#include "itemgroup.h"
|
2017-01-31 14:18:52 +01:00
|
|
|
#include "itemdef.h"
|
2017-05-21 14:40:55 +02:00
|
|
|
#include "c_types.h"
|
2018-01-20 14:09:58 +01:00
|
|
|
#include "hud.h"
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2013-09-02 02:01:49 +02:00
|
|
|
namespace Json { class Value; }
|
|
|
|
|
2013-06-06 22:57:38 +02:00
|
|
|
struct MapNode;
|
2018-02-10 21:04:16 +01:00
|
|
|
class NodeDefManager;
|
2013-06-06 22:57:38 +02:00
|
|
|
struct PointedThing;
|
|
|
|
struct ItemStack;
|
|
|
|
struct ItemDefinition;
|
|
|
|
struct ToolCapabilities;
|
|
|
|
struct ObjectProperties;
|
|
|
|
struct SimpleSoundSpec;
|
|
|
|
struct ServerSoundParams;
|
2013-05-25 00:51:02 +02:00
|
|
|
class Inventory;
|
2013-06-06 22:57:38 +02:00
|
|
|
struct NodeBox;
|
|
|
|
struct ContentFeatures;
|
|
|
|
struct TileDef;
|
2013-05-25 00:51:02 +02:00
|
|
|
class Server;
|
|
|
|
struct DigParams;
|
|
|
|
struct HitParams;
|
|
|
|
struct EnumString;
|
|
|
|
struct NoiseParams;
|
2014-11-13 05:01:13 +01:00
|
|
|
class Schematic;
|
2013-05-25 00:51:02 +02:00
|
|
|
|
|
|
|
|
2015-07-03 05:14:30 +02:00
|
|
|
ContentFeatures read_content_features (lua_State *L, int index);
|
2017-05-21 14:40:55 +02:00
|
|
|
void push_content_features (lua_State *L,
|
|
|
|
const ContentFeatures &c);
|
|
|
|
|
|
|
|
void push_nodebox (lua_State *L,
|
|
|
|
const NodeBox &box);
|
|
|
|
void push_box (lua_State *L,
|
|
|
|
const std::vector<aabb3f> &box);
|
|
|
|
|
|
|
|
void push_palette (lua_State *L,
|
|
|
|
const std::vector<video::SColor> *palette);
|
|
|
|
|
2015-08-05 22:52:32 +02:00
|
|
|
TileDef read_tiledef (lua_State *L, int index,
|
|
|
|
u8 drawtype);
|
2017-05-21 14:40:55 +02:00
|
|
|
|
2015-07-03 05:14:30 +02:00
|
|
|
void read_soundspec (lua_State *L, int index,
|
|
|
|
SimpleSoundSpec &spec);
|
|
|
|
NodeBox read_nodebox (lua_State *L, int index);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2015-07-03 05:14:30 +02:00
|
|
|
void read_server_sound_params (lua_State *L, int index,
|
|
|
|
ServerSoundParams ¶ms);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2015-07-03 05:14:30 +02:00
|
|
|
void push_dig_params (lua_State *L,
|
|
|
|
const DigParams ¶ms);
|
|
|
|
void push_hit_params (lua_State *L,
|
|
|
|
const HitParams ¶ms);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2017-01-31 14:18:52 +01:00
|
|
|
ItemStack read_item (lua_State *L, int index, IItemDefManager *idef);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2017-01-14 16:48:49 +01:00
|
|
|
struct TileAnimationParams read_animation_definition(lua_State *L, int index);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2015-07-03 05:14:30 +02:00
|
|
|
ToolCapabilities read_tool_capabilities (lua_State *L, int table);
|
2013-05-25 00:51:02 +02:00
|
|
|
void push_tool_capabilities (lua_State *L,
|
|
|
|
const ToolCapabilities &prop);
|
|
|
|
|
2017-04-19 23:02:07 +02:00
|
|
|
void read_item_definition (lua_State *L, int index, const ItemDefinition &default_def,
|
|
|
|
ItemDefinition &def);
|
2017-04-29 12:08:16 +02:00
|
|
|
void push_item_definition (lua_State *L,
|
|
|
|
const ItemDefinition &i);
|
2017-05-21 14:40:55 +02:00
|
|
|
void push_item_definition_full (lua_State *L,
|
|
|
|
const ItemDefinition &i);
|
|
|
|
|
2015-07-03 05:14:30 +02:00
|
|
|
void read_object_properties (lua_State *L, int index,
|
2017-03-10 18:25:58 +01:00
|
|
|
ObjectProperties *prop,
|
|
|
|
IItemDefManager *idef);
|
2015-07-03 05:14:30 +02:00
|
|
|
void push_object_properties (lua_State *L,
|
2013-05-25 00:51:02 +02:00
|
|
|
ObjectProperties *prop);
|
|
|
|
|
2013-08-11 04:09:45 +02:00
|
|
|
void push_inventory_list (lua_State *L,
|
|
|
|
Inventory *inv,
|
|
|
|
const char *name);
|
2015-07-03 05:14:30 +02:00
|
|
|
void read_inventory_list (lua_State *L, int tableindex,
|
|
|
|
Inventory *inv, const char *name,
|
|
|
|
Server *srv, int forcesize=-1);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2015-07-03 05:14:30 +02:00
|
|
|
MapNode readnode (lua_State *L, int index,
|
2018-02-10 21:04:16 +01:00
|
|
|
const NodeDefManager *ndef);
|
2015-07-03 05:14:30 +02:00
|
|
|
void pushnode (lua_State *L, const MapNode &n,
|
2018-02-10 21:04:16 +01:00
|
|
|
const NodeDefManager *ndef);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
|
|
|
|
2015-07-03 05:14:30 +02:00
|
|
|
void read_groups (lua_State *L, int index,
|
2016-10-05 09:03:55 +02:00
|
|
|
ItemGroupList &result);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2015-07-03 05:14:30 +02:00
|
|
|
void push_groups (lua_State *L,
|
2016-10-05 09:03:55 +02:00
|
|
|
const ItemGroupList &groups);
|
2015-07-03 05:14:30 +02:00
|
|
|
|
2013-05-25 00:51:02 +02:00
|
|
|
//TODO rename to "read_enum_field"
|
2015-07-03 05:14:30 +02:00
|
|
|
int getenumfield (lua_State *L, int table,
|
2013-05-25 00:51:02 +02:00
|
|
|
const char *fieldname,
|
|
|
|
const EnumString *spec,
|
|
|
|
int default_);
|
|
|
|
|
2014-03-08 17:34:46 +01:00
|
|
|
bool getflagsfield (lua_State *L, int table,
|
2013-05-25 00:51:02 +02:00
|
|
|
const char *fieldname,
|
2014-03-08 17:34:46 +01:00
|
|
|
FlagDesc *flagdesc,
|
|
|
|
u32 *flags, u32 *flagmask);
|
|
|
|
|
|
|
|
bool read_flags (lua_State *L, int index,
|
|
|
|
FlagDesc *flagdesc,
|
|
|
|
u32 *flags, u32 *flagmask);
|
2015-07-03 05:14:30 +02:00
|
|
|
|
|
|
|
void push_flags_string (lua_State *L, FlagDesc *flagdesc,
|
|
|
|
u32 flags, u32 flagmask);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2014-02-09 18:38:50 +01:00
|
|
|
u32 read_flags_table (lua_State *L, int table,
|
|
|
|
FlagDesc *flagdesc, u32 *flagmask);
|
|
|
|
|
2013-05-25 00:51:02 +02:00
|
|
|
void push_items (lua_State *L,
|
|
|
|
const std::vector<ItemStack> &items);
|
|
|
|
|
|
|
|
std::vector<ItemStack> read_items (lua_State *L,
|
|
|
|
int index,
|
|
|
|
Server* srv);
|
|
|
|
|
2017-05-21 14:40:55 +02:00
|
|
|
void push_soundspec (lua_State *L,
|
|
|
|
const SimpleSoundSpec &spec);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
|
|
|
bool string_to_enum (const EnumString *spec,
|
|
|
|
int &result,
|
|
|
|
const std::string &str);
|
|
|
|
|
2014-12-08 03:57:12 +01:00
|
|
|
bool read_noiseparams (lua_State *L, int index,
|
2014-02-16 00:20:15 +01:00
|
|
|
NoiseParams *np);
|
2015-07-03 05:14:30 +02:00
|
|
|
void push_noiseparams (lua_State *L, NoiseParams *np);
|
2013-06-22 06:29:44 +02:00
|
|
|
|
2013-05-25 00:51:02 +02:00
|
|
|
void luaentity_get (lua_State *L,u16 id);
|
|
|
|
|
2013-09-02 02:01:49 +02:00
|
|
|
bool push_json_value (lua_State *L,
|
|
|
|
const Json::Value &value,
|
|
|
|
int nullindex);
|
2015-07-03 05:14:30 +02:00
|
|
|
void read_json_value (lua_State *L, Json::Value &root,
|
|
|
|
int index, u8 recursion = 0);
|
2013-09-02 02:01:49 +02:00
|
|
|
|
2018-08-16 20:10:08 +02:00
|
|
|
/*!
|
|
|
|
* Pushes a Lua `pointed_thing` to the given Lua stack.
|
|
|
|
* \param csm If true, a client side pointed thing is pushed
|
|
|
|
* \param hitpoint If true, the exact pointing location is also pushed
|
|
|
|
*/
|
|
|
|
void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm =
|
|
|
|
false, bool hitpoint = false);
|
2017-04-29 12:08:16 +02:00
|
|
|
|
|
|
|
void push_objectRef (lua_State *L, const u16 id);
|
|
|
|
|
2018-01-20 14:09:58 +01:00
|
|
|
void read_hud_element (lua_State *L, HudElement *elem);
|
|
|
|
|
|
|
|
void push_hud_element (lua_State *L, HudElement *elem);
|
|
|
|
|
|
|
|
HudElementStat read_hud_change (lua_State *L, HudElement *elem, void **value);
|
|
|
|
|
2016-11-14 15:28:06 +01:00
|
|
|
extern struct EnumString es_TileAnimationType[];
|