49 changes: 0 additions & 49 deletions src/script/lua_api/l_localplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,34 +203,6 @@ int LuaLocalPlayer::l_get_breath(lua_State *L)
return 1;
}

int LuaLocalPlayer::l_get_look_dir(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);

float pitch = -1.0 * player->getPitch() * core::DEGTORAD;
float yaw = (player->getYaw() + 90.) * core::DEGTORAD;
v3f v(cos(pitch) * cos(yaw), sin(pitch), cos(pitch) * sin(yaw));

push_v3f(L, v);
return 1;
}

int LuaLocalPlayer::l_get_look_horizontal(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);

lua_pushnumber(L, (player->getYaw() + 90.) * core::DEGTORAD);
return 1;
}

int LuaLocalPlayer::l_get_look_vertical(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);

lua_pushnumber(L, -1.0 * player->getPitch() * core::DEGTORAD);
return 1;
}

int LuaLocalPlayer::l_get_pos(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
Expand All @@ -239,22 +211,6 @@ int LuaLocalPlayer::l_get_pos(lua_State *L)
return 1;
}

int LuaLocalPlayer::l_get_eye_pos(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);

push_v3f(L, player->getEyePosition());
return 1;
}

int LuaLocalPlayer::l_get_eye_offset(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);

push_v3f(L, player->getEyeOffset());
return 1;
}

int LuaLocalPlayer::l_get_movement_acceleration(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
Expand Down Expand Up @@ -393,12 +349,7 @@ const luaL_Reg LuaLocalPlayer::methods[] = {
luamethod(LuaLocalPlayer, get_last_look_vertical),
luamethod(LuaLocalPlayer, get_key_pressed),
luamethod(LuaLocalPlayer, get_breath),
luamethod(LuaLocalPlayer, get_look_dir),
luamethod(LuaLocalPlayer, get_look_horizontal),
luamethod(LuaLocalPlayer, get_look_vertical),
luamethod(LuaLocalPlayer, get_pos),
luamethod(LuaLocalPlayer, get_eye_pos),
luamethod(LuaLocalPlayer, get_eye_offset),
luamethod(LuaLocalPlayer, get_movement_acceleration),
luamethod(LuaLocalPlayer, get_movement_speed),
luamethod(LuaLocalPlayer, get_movement),
Expand Down
7 changes: 0 additions & 7 deletions src/script/lua_api/l_localplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,8 @@ class LuaLocalPlayer : public ModApiBase

static int l_get_breath(lua_State *L);

static int l_get_look_dir(lua_State *L);
static int l_get_look_horizontal(lua_State *L);
static int l_get_look_vertical(lua_State *L);

static int l_get_pos(lua_State *L);

static int l_get_eye_pos(lua_State *L);
static int l_get_eye_offset(lua_State *L);

static int l_get_movement_acceleration(lua_State *L);

static int l_get_movement_speed(lua_State *L);
Expand Down
7 changes: 7 additions & 0 deletions src/script/scripting_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_item.h"
#include "lua_api/l_nodemeta.h"
#include "lua_api/l_localplayer.h"
#include "lua_api/l_camera.h"

ClientScripting::ClientScripting(Client *client):
ScriptApiBase()
Expand Down Expand Up @@ -71,10 +72,16 @@ void ClientScripting::InitializeModApi(lua_State *L, int top)
LuaMinimap::Register(L);
NodeMetaRef::RegisterClient(L);
LuaLocalPlayer::Register(L);
LuaCamera::Register(L);
}

void ClientScripting::on_client_ready(LocalPlayer *localplayer)
{
lua_State *L = getStack();
LuaLocalPlayer::create(L, localplayer);
}

void ClientScripting::on_camera_ready(Camera *camera)
{
LuaCamera::create(getStack(), camera);
}
2 changes: 2 additions & 0 deletions src/script/scripting_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,

class Client;
class LocalPlayer;
class Camera;
class ClientScripting:
virtual public ScriptApiBase,
public ScriptApiSecurity,
Expand All @@ -36,6 +37,7 @@ class ClientScripting:
public:
ClientScripting(Client *client);
void on_client_ready(LocalPlayer *localplayer);
void on_camera_ready(Camera *camera);

private:
virtual void InitializeModApi(lua_State *L, int top);
Expand Down