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_clientobject.cpp9
-rw-r--r--src/script/lua_api/l_clientobject.h3
-rw-r--r--src/script/lua_api/l_inventoryaction.cpp2
-rw-r--r--src/script/lua_api/l_localplayer.cpp4
4 files changed, 15 insertions, 3 deletions
diff --git a/src/script/lua_api/l_clientobject.cpp b/src/script/lua_api/l_clientobject.cpp
index 90f0bcd15..d88b538a1 100644
--- a/src/script/lua_api/l_clientobject.cpp
+++ b/src/script/lua_api/l_clientobject.cpp
@@ -87,6 +87,14 @@ int ClientObjectRef::l_is_player(lua_State *L)
return 1;
}
+int ClientObjectRef::l_is_local_player(lua_State *L)
+{
+ ClientObjectRef *ref = checkobject(L, 1);
+ GenericCAO *gcao = get_generic_cao(ref, L);
+ lua_pushboolean(L, gcao->isLocalPlayer());
+ return 1;
+}
+
int ClientObjectRef::l_get_name(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
@@ -210,6 +218,7 @@ luaL_Reg ClientObjectRef::methods[] = {luamethod(ClientObjectRef, get_pos),
luamethod(ClientObjectRef, get_acceleration),
luamethod(ClientObjectRef, get_rotation),
luamethod(ClientObjectRef, is_player),
+ luamethod(ClientObjectRef, is_local_player),
luamethod(ClientObjectRef, get_name),
luamethod(ClientObjectRef, get_attach),
luamethod(ClientObjectRef, get_nametag),
diff --git a/src/script/lua_api/l_clientobject.h b/src/script/lua_api/l_clientobject.h
index 88a6956bc..521591444 100644
--- a/src/script/lua_api/l_clientobject.h
+++ b/src/script/lua_api/l_clientobject.h
@@ -60,6 +60,9 @@ private:
// is_player(self)
static int l_is_player(lua_State *L);
+
+ // is_local_player(self)
+ static int l_is_local_player(lua_State *L);
// get_name(self)
static int l_get_name(lua_State *L);
diff --git a/src/script/lua_api/l_inventoryaction.cpp b/src/script/lua_api/l_inventoryaction.cpp
index 516d6d3b2..f3037ba83 100644
--- a/src/script/lua_api/l_inventoryaction.cpp
+++ b/src/script/lua_api/l_inventoryaction.cpp
@@ -133,7 +133,7 @@ void LuaInventoryAction::readFullInventoryLocationInto(lua_State *L, InventoryLo
loc->deSerialize(readParam<std::string>(L, 2));
std::string l = readParam<std::string>(L, 3);
*list = l;
- *index = luaL_checkinteger(L, 4);
+ *index = luaL_checkinteger(L, 4) - 1;
} catch (SerializationError &) {}
}
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp
index 8057802a4..e40dd7b37 100644
--- a/src/script/lua_api/l_localplayer.cpp
+++ b/src/script/lua_api/l_localplayer.cpp
@@ -116,7 +116,7 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
- lua_pushinteger(L, player->getWieldIndex());
+ lua_pushinteger(L, player->getWieldIndex() + 1);
return 1;
}
@@ -124,7 +124,7 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
int LuaLocalPlayer::l_set_wield_index(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
- u32 index = luaL_checkinteger(L, 2);
+ u32 index = luaL_checkinteger(L, 2) - 1;
player->setWieldIndex(index);
g_game->processItemSelection(&g_game->runData.new_playeritem);