1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

[CSM] Add local node meta reference. (#5508)

This commit is contained in:
red-001 2017-04-04 06:41:37 +01:00 committed by Loïc Blot
parent 859141a0ce
commit 000ec26001
6 changed files with 91 additions and 12 deletions

View file

@ -25,8 +25,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gettext.h"
#include "l_internal.h"
#include "lua_api/l_item.h"
#include "lua_api/l_nodemeta.h"
#include "mainmenumanager.h"
#include "util/string.h"
#include "clientenvironment.h"
#include "map.h"
extern MainGameCallback *g_gamecallback;
@ -182,6 +185,15 @@ int ModApiClient::l_get_wielded_item(lua_State *L)
return 1;
}
// get_meta(pos)
int ModApiClient::l_get_meta(lua_State *L)
{
v3s16 p = read_v3s16(L, 1);
NodeMetadata *meta = getClient(L)->getEnv().getMap().getNodeMetadata(p);
NodeMetaRef::createClient(L, meta);
return 1;
}
void ModApiClient::Initialize(lua_State *L, int top)
{
API_FCT(get_current_modname);
@ -196,4 +208,5 @@ void ModApiClient::Initialize(lua_State *L, int top)
API_FCT(get_node_or_nil);
API_FCT(get_wielded_item);
API_FCT(disconnect);
API_FCT(get_meta);
}