mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 14:01:49 +00:00
added hud.get_player()
This commit is contained in:
parent
7be1c3f223
commit
e0e052ff1a
2 changed files with 9 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
function setup_variables()
|
function setup_variables()
|
||||||
local x,y,z = player.get_pos(0)
|
local x,y,z = player.get_pos(hud.get_player())
|
||||||
console.set('pos.x', x)
|
console.set('pos.x', x)
|
||||||
console.set('pos.y', y)
|
console.set('pos.y', y)
|
||||||
console.set('pos.z', z)
|
console.set('pos.z', z)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "../../../graphics/ui/elements/InventoryView.hpp"
|
#include "../../../graphics/ui/elements/InventoryView.hpp"
|
||||||
#include "../../../items/Inventories.hpp"
|
#include "../../../items/Inventories.hpp"
|
||||||
#include "../../../logic/BlocksController.hpp"
|
#include "../../../logic/BlocksController.hpp"
|
||||||
|
#include "../../../objects/Player.hpp"
|
||||||
#include "../../../util/stringutil.hpp"
|
#include "../../../util/stringutil.hpp"
|
||||||
#include "../../../voxels/Block.hpp"
|
#include "../../../voxels/Block.hpp"
|
||||||
#include "../../../voxels/Chunks.hpp"
|
#include "../../../voxels/Chunks.hpp"
|
||||||
|
|
@ -121,6 +122,12 @@ static int l_hud_get_block_inventory(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_hud_get_player(lua_State* L) {
|
||||||
|
auto player = scripting::hud->getPlayer();
|
||||||
|
lua_pushinteger(L, player->getId());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg hudlib [] = {
|
const luaL_Reg hudlib [] = {
|
||||||
{"open_inventory", lua_wrap_errors<l_hud_open_inventory>},
|
{"open_inventory", lua_wrap_errors<l_hud_open_inventory>},
|
||||||
{"close_inventory", lua_wrap_errors<l_hud_close_inventory>},
|
{"close_inventory", lua_wrap_errors<l_hud_close_inventory>},
|
||||||
|
|
@ -131,5 +138,6 @@ const luaL_Reg hudlib [] = {
|
||||||
{"close", lua_wrap_errors<l_hud_close>},
|
{"close", lua_wrap_errors<l_hud_close>},
|
||||||
{"pause", lua_wrap_errors<l_hud_pause>},
|
{"pause", lua_wrap_errors<l_hud_pause>},
|
||||||
{"resume", lua_wrap_errors<l_hud_resume>},
|
{"resume", lua_wrap_errors<l_hud_resume>},
|
||||||
|
{"get_player", lua_wrap_errors<l_hud_get_player>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue