Update .wielded command to output the entire itemstring; add LocalPlayer:get_hotbar_size
This commit is contained in:
parent
1669682324
commit
7613d9bfe6
@ -69,7 +69,7 @@ core.register_chatcommand("teleport", {
|
||||
core.register_chatcommand("wielded", {
|
||||
description = "Print itemstring of wieleded item",
|
||||
func = function()
|
||||
return true, core.localplayer:get_wielded_item():get_name()
|
||||
return true, core.localplayer:get_wielded_item():to_string()
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -476,6 +476,7 @@ int LuaLocalPlayer::l_hud_get(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get_object(self)
|
||||
int LuaLocalPlayer::l_get_object(lua_State *L)
|
||||
{
|
||||
LocalPlayer *player = getobject(L, 1);
|
||||
@ -487,6 +488,15 @@ int LuaLocalPlayer::l_get_object(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get_hotbar_size(self)
|
||||
int LuaLocalPlayer::l_get_hotbar_size(lua_State *L)
|
||||
{
|
||||
LocalPlayer *player = getobject(L, 1);
|
||||
lua_pushnumber(L, player->hud_hotbar_itemcount);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
LuaLocalPlayer *LuaLocalPlayer::checkobject(lua_State *L, int narg)
|
||||
{
|
||||
luaL_checktype(L, narg, LUA_TUSERDATA);
|
||||
@ -585,6 +595,7 @@ const luaL_Reg LuaLocalPlayer::methods[] = {
|
||||
luamethod(LuaLocalPlayer, hud_change),
|
||||
luamethod(LuaLocalPlayer, hud_get),
|
||||
luamethod(LuaLocalPlayer, get_object),
|
||||
luamethod(LuaLocalPlayer, get_hotbar_size),
|
||||
|
||||
{0, 0}
|
||||
};
|
||||
|
@ -65,6 +65,9 @@ private:
|
||||
// get_wielded_item(self)
|
||||
static int l_get_wielded_item(lua_State *L);
|
||||
|
||||
// get_hotbar_size(self)
|
||||
static int l_get_hotbar_size(lua_State *L);
|
||||
|
||||
static int l_is_attached(lua_State *L);
|
||||
static int l_is_touching_ground(lua_State *L);
|
||||
static int l_is_in_liquid(lua_State *L);
|
||||
|
Loading…
x
Reference in New Issue
Block a user