voxelcore/dev/tests/hotbar.lua
ostermine aa670f3c9d make hotbar size and layout configurable
Add hotbar-size, hotbar-layout and inventory-layout to config/defaults.toml,
player.get_hotbar_size / player.set_hotbar_size and
hud.is_hotbar_visible / hud.set_hotbar_visible.
2026-10-15 15:58:56 +03:00

27 lines
796 B
Lua

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")