]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/script/lua_api/l_localplayer.cpp
UI Update; Added AutoTool
[dragonfireclient.git] / src / script / lua_api / l_localplayer.cpp
index 851ede53570dda8e68dde7559872017e8b3083b3..2644893f91cce9e1e44fe9f879b60233ef935e21 100644 (file)
@@ -24,7 +24,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "client/localplayer.h"
 #include "hud.h"
 #include "common/c_content.h"
+#include "client/client.h"
 #include "client/content_cao.h"
+#include "client/game.h"
 
 LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m) : m_localplayer(m)
 {
@@ -85,6 +87,17 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
        return 1;
 }
 
+// set_wield_index(self)
+int LuaLocalPlayer::l_set_wield_index(lua_State *L)
+{
+       LocalPlayer *player = getobject(L, 1);
+       u32 index = luaL_checkinteger(L, 2);
+       
+       player->setWieldIndex(index);
+       g_game->processItemSelection(&g_game->runData.new_playeritem);
+       return 0;
+}
+
 // get_wielded_item(self)
 int LuaLocalPlayer::l_get_wielded_item(lua_State *L)
 {
@@ -255,6 +268,17 @@ int LuaLocalPlayer::l_get_pos(lua_State *L)
        return 1;
 }
 
+// set_pos(self, pos)
+int LuaLocalPlayer::l_set_pos(lua_State *L)
+{
+       LocalPlayer *player = getobject(L, 1);
+       
+       v3f pos = checkFloatPos(L, 2);
+       player->setPosition(pos);
+       getClient(L)->sendPlayerPos();
+       return 0;
+}
+
 // get_movement_acceleration(self)
 int LuaLocalPlayer::l_get_movement_acceleration(lua_State *L)
 {
@@ -456,6 +480,7 @@ const luaL_Reg LuaLocalPlayer::methods[] = {
                luamethod(LuaLocalPlayer, get_hp),
                luamethod(LuaLocalPlayer, get_name),
                luamethod(LuaLocalPlayer, get_wield_index),
+               luamethod(LuaLocalPlayer, set_wield_index),
                luamethod(LuaLocalPlayer, get_wielded_item),
                luamethod(LuaLocalPlayer, is_attached),
                luamethod(LuaLocalPlayer, is_touching_ground),
@@ -474,6 +499,7 @@ const luaL_Reg LuaLocalPlayer::methods[] = {
                luamethod(LuaLocalPlayer, get_control),
                luamethod(LuaLocalPlayer, get_breath),
                luamethod(LuaLocalPlayer, get_pos),
+               luamethod(LuaLocalPlayer, set_pos),
                luamethod(LuaLocalPlayer, get_movement_acceleration),
                luamethod(LuaLocalPlayer, get_movement_speed),
                luamethod(LuaLocalPlayer, get_movement),