aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/defaultsettings.cpp1
-rw-r--r--src/script/common/c_content.cpp7
-rw-r--r--src/script/lua_api/l_clientobject.cpp28
-rw-r--r--src/script/lua_api/l_clientobject.h7
4 files changed, 39 insertions, 4 deletions
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 96c4e0688..530bfcd8a 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -108,6 +108,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("block_water", "false");
settings->setDefault("autotnt", "false");
settings->setDefault("replace", "false");
+ settings->setDefault("crystal_pvp", "false");
// Keymap
settings->setDefault("remote_port", "30000");
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 9efa2c57f..7d4c1e748 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "object_properties.h"
#include "collision.h"
#include "cpp_api/s_node.h"
+#include "lua_api/l_clientobject.h"
#include "lua_api/l_object.h"
#include "lua_api/l_item.h"
#include "common/c_internal.h"
@@ -1838,12 +1839,12 @@ void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm,
lua_setfield(L, -2, "type");
if (csm) {
- lua_pushinteger(L, pointed.object_id);
- lua_setfield(L, -2, "id");
+ ClientObjectRef::create(L, pointed.object_id);
} else {
push_objectRef(L, pointed.object_id);
- lua_setfield(L, -2, "ref");
}
+
+ lua_setfield(L, -2, "ref");
} else {
lua_pushstring(L, "nothing");
lua_setfield(L, -2, "type");
diff --git a/src/script/lua_api/l_clientobject.cpp b/src/script/lua_api/l_clientobject.cpp
index 462de1a09..90f0bcd15 100644
--- a/src/script/lua_api/l_clientobject.cpp
+++ b/src/script/lua_api/l_clientobject.cpp
@@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/c_converter.h"
#include "client/client.h"
#include "object_properties.h"
+#include "util/pointedthing.h"
ClientObjectRef *ClientObjectRef::checkobject(lua_State *L, int narg)
{
@@ -133,6 +134,24 @@ int ClientObjectRef::l_get_max_hp(lua_State *L)
return 1;
}
+int ClientObjectRef::l_punch(lua_State *L)
+{
+ ClientObjectRef *ref = checkobject(L, 1);
+ GenericCAO *gcao = get_generic_cao(ref, L);
+ PointedThing pointed(gcao->getId(), v3f(0,0,0), v3s16(0,0,0), 0);
+ getClient(L)->interact(INTERACT_START_DIGGING, pointed);
+ return 0;
+}
+
+int ClientObjectRef::l_rightclick(lua_State *L)
+{
+ ClientObjectRef *ref = checkobject(L, 1);
+ GenericCAO *gcao = get_generic_cao(ref, L);
+ PointedThing pointed(gcao->getId(), v3f(0,0,0), v3s16(0,0,0), 0);
+ getClient(L)->interact(INTERACT_PLACE, pointed);
+ return 0;
+}
+
ClientObjectRef::ClientObjectRef(ClientActiveObject *object) : m_object(object)
{
}
@@ -147,6 +166,11 @@ void ClientObjectRef::create(lua_State *L, ClientActiveObject *object)
}
}
+void ClientObjectRef::create(lua_State *L, s16 id)
+{
+ create(L, ((ClientEnvironment *)getEnv(L))->getActiveObject(id));
+}
+
int ClientObjectRef::gc_object(lua_State *L)
{
ClientObjectRef *obj = *(ClientObjectRef **)(lua_touserdata(L, 1));
@@ -190,4 +214,6 @@ luaL_Reg ClientObjectRef::methods[] = {luamethod(ClientObjectRef, get_pos),
luamethod(ClientObjectRef, get_attach),
luamethod(ClientObjectRef, get_nametag),
luamethod(ClientObjectRef, get_item_textures),
- luamethod(ClientObjectRef, get_max_hp), {0, 0}};
+ luamethod(ClientObjectRef, get_max_hp),
+ luamethod(ClientObjectRef, punch),
+ luamethod(ClientObjectRef, rightclick), {0, 0}};
diff --git a/src/script/lua_api/l_clientobject.h b/src/script/lua_api/l_clientobject.h
index 3022555f5..88a6956bc 100644
--- a/src/script/lua_api/l_clientobject.h
+++ b/src/script/lua_api/l_clientobject.h
@@ -31,6 +31,7 @@ public:
static void Register(lua_State *L);
static void create(lua_State *L, ClientActiveObject *object);
+ static void create(lua_State *L, s16 id);
static ClientObjectRef *checkobject(lua_State *L, int narg);
@@ -74,4 +75,10 @@ private:
// get_hp(self)
static int l_get_max_hp(lua_State *L);
+
+ // punch(self)
+ static int l_punch(lua_State *L);
+
+ // rightclick(self)
+ static int l_rightclick(lua_State *L);
};