mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 18:09:46 +00:00
Merge pull request #1043 from ostermine/feat/hotbar-control
make hotbar size and layout configurable
This commit is contained in:
commit
bb73e3f354
16 changed files with 188 additions and 20 deletions
|
|
@ -194,6 +194,15 @@ static int l_set_allow_pause(lua::State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_is_hotbar_visible(lua::State* L) {
|
||||
return lua::pushboolean(L, hud->isHotbarVisible());
|
||||
}
|
||||
|
||||
static int l_set_hotbar_visible(lua::State* L) {
|
||||
hud->setHotbarVisible(lua::toboolean(L, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_reload_script(lua::State* L) {
|
||||
auto packid = lua::require_string(L, 1);
|
||||
if (content == nullptr) {
|
||||
|
|
@ -237,6 +246,8 @@ const luaL_Reg hudlib[] = {
|
|||
{"_set_content_access", wrap_hud<l_set_content_access>},
|
||||
{"_set_debug_cheats", wrap_hud<l_set_debug_cheats>},
|
||||
{"set_allow_pause", wrap_hud<l_set_allow_pause>},
|
||||
{"is_hotbar_visible", wrap_hud<l_is_hotbar_visible>},
|
||||
{"set_hotbar_visible", wrap_hud<l_set_hotbar_visible>},
|
||||
{"reload_script", wrap_hud<l_reload_script>},
|
||||
{"is_open", wrap_hud<l_is_open>},
|
||||
{nullptr, nullptr}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,21 @@ static int l_get_inv(lua::State* L) {
|
|||
|
||||
static int l_set_selected_slot(lua::State* L) {
|
||||
if (auto player = get_player(L, 1)) {
|
||||
player->setChosenSlot(lua::tointeger(L, 2) % 10);
|
||||
player->setChosenSlot(lua::tointeger(L, 2) % player->getHotbarSize());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_get_hotbar_size(lua::State* L) {
|
||||
if (auto player = get_player(L, 1)) {
|
||||
return lua::pushinteger(L, player->getHotbarSize());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_set_hotbar_size(lua::State* L) {
|
||||
if (auto player = get_player(L, 1)) {
|
||||
player->setHotbarSize(lua::tointeger(L, 2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -401,6 +415,8 @@ const luaL_Reg playerlib[] = {
|
|||
{"get_interaction_distance", lua::wrap<l_get_interaction_distance>},
|
||||
{"set_interaction_distance", lua::wrap<l_set_interaction_distance>},
|
||||
{"set_selected_slot", lua::wrap<l_set_selected_slot>},
|
||||
{"get_hotbar_size", lua::wrap<l_get_hotbar_size>},
|
||||
{"set_hotbar_size", lua::wrap<l_set_hotbar_size>},
|
||||
{"get_selected_block", lua::wrap<l_get_selected_block>},
|
||||
{"get_selected_entity", lua::wrap<l_get_selected_entity>},
|
||||
{"set_spawnpoint", lua::wrap<l_set_spawnpoint>},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue