aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_client.cpp10
-rw-r--r--src/script/lua_api/l_client.h3
-rw-r--r--src/script/lua_api/l_localplayer.cpp32
-rw-r--r--src/script/lua_api/l_localplayer.h6
4 files changed, 49 insertions, 2 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp
index 1bc4829d4..44311be68 100644
--- a/src/script/lua_api/l_client.cpp
+++ b/src/script/lua_api/l_client.cpp
@@ -524,6 +524,14 @@ int ModApiClient::l_get_objects_inside_radius(lua_State *L)
return 1;
}
+//take_screenshot()
+int ModApiClient::l_take_screenshot(lua_State *L)
+{
+ getClient(L)->makeScreenshot();
+ lua_pushboolean(L, true);
+ return 1;
+}
+
void ModApiClient::Initialize(lua_State *L, int top)
{
API_FCT(get_current_modname);
@@ -558,4 +566,6 @@ void ModApiClient::Initialize(lua_State *L, int top)
API_FCT(set_keypress);
API_FCT(drop_selected_item);
API_FCT(get_objects_inside_radius);
+ API_FCT(take_screenshot);
+
}
diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h
index 5863e5717..04cc23041 100644
--- a/src/script/lua_api/l_client.h
+++ b/src/script/lua_api/l_client.h
@@ -126,6 +126,9 @@ private:
// get_objects_inside_radius(pos, radius)
static int l_get_objects_inside_radius(lua_State *L);
+ //take_screenshot()
+ static int l_take_screenshot(lua_State *L);
+
public:
static void Initialize(lua_State *L, int top);
};
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp
index 789b3a3f0..d94668ed4 100644
--- a/src/script/lua_api/l_localplayer.cpp
+++ b/src/script/lua_api/l_localplayer.cpp
@@ -95,6 +95,30 @@ int LuaLocalPlayer::l_set_yaw(lua_State *L)
return 0;
}
+int LuaLocalPlayer::l_get_pitch(lua_State *L)
+{
+ LocalPlayer *player = getobject(L, 1);
+
+ lua_pushinteger(L, player->getPitch());
+ return 1;
+}
+
+
+int LuaLocalPlayer::l_set_pitch(lua_State *L)
+{
+ LocalPlayer *player = getobject(L, 1);
+
+ if (lua_isnumber(L, 2)) {
+ int pitch = lua_tonumber(L, 2);
+ player->setPitch(pitch);
+ g_game->cam_view.camera_pitch = pitch;
+ g_game->cam_view_target.camera_pitch = pitch;
+ }
+
+ return 0;
+}
+
+
int LuaLocalPlayer::l_get_hp(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
@@ -524,8 +548,12 @@ void LuaLocalPlayer::Register(lua_State *L)
const char LuaLocalPlayer::className[] = "LocalPlayer";
const luaL_Reg LuaLocalPlayer::methods[] = {luamethod(LuaLocalPlayer, get_velocity),
luamethod(LuaLocalPlayer, set_velocity),
- luamethod(LuaLocalPlayer, get_yaw), luamethod(LuaLocalPlayer, set_yaw),
- luamethod(LuaLocalPlayer, get_hp), luamethod(LuaLocalPlayer, get_name),
+ luamethod(LuaLocalPlayer, get_yaw),
+ luamethod(LuaLocalPlayer, set_yaw),
+ luamethod(LuaLocalPlayer, get_pitch),
+ luamethod(LuaLocalPlayer, set_pitch),
+ luamethod(LuaLocalPlayer, get_hp),
+ luamethod(LuaLocalPlayer, get_name),
luamethod(LuaLocalPlayer, get_wield_index),
luamethod(LuaLocalPlayer, set_wield_index),
luamethod(LuaLocalPlayer, get_wielded_item),
diff --git a/src/script/lua_api/l_localplayer.h b/src/script/lua_api/l_localplayer.h
index 8daa901e0..1d7f9fcbd 100644
--- a/src/script/lua_api/l_localplayer.h
+++ b/src/script/lua_api/l_localplayer.h
@@ -44,6 +44,12 @@ private:
// set_yaw(self, yaw)
static int l_set_yaw(lua_State *L);
+ // get_pitch(self)
+ static int l_get_pitch(lua_State *L);
+
+ // set_pitch(self,pitch)
+ static int l_set_pitch(lua_State *L);
+
// get_hp(self)
static int l_get_hp(lua_State *L);