Merge pull request #1043 from ostermine/feat/hotbar-control

make hotbar size and layout configurable
This commit is contained in:
MihailRis 2026-10-18 11:38:10 +03:00 • committed by GitHub
commit bb73e3f354
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 188 additions and 20 deletions

27
dev/tests/hotbar.lua Normal file
View file

@ -0,0 +1,27 @@
local util = require "core:tests_util"
util.create_demo_world("core:default")
local pid = player.create("Xerxes")
local function selected_slot()
local _, slot = player.get_inventory(pid)
return slot
end
util.check_int(10, player.get_hotbar_size(pid), "default hotbar size")
player.set_selected_slot(pid, 12)
util.check_int(2, selected_slot(), "selected slot")
player.set_selected_slot(pid, 8)
player.set_hotbar_size(pid, 5)
util.check_int(5, player.get_hotbar_size(pid), "hotbar size")
util.check_int(4, selected_slot(), "clamped selected slot")
player.set_selected_slot(pid, 7)
util.check_int(2, selected_slot(), "selected slot")
player.set_hotbar_size(pid, 0)
util.check_int(1, player.get_hotbar_size(pid), "min hotbar size")
util.check_int(0, selected_slot(), "selected slot")