mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 09:29:44 +00:00
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.
This commit is contained in:
parent
2e2233a489
commit
aa670f3c9d
16 changed files with 188 additions and 20 deletions
27
dev/tests/hotbar.lua
Normal file
27
dev/tests/hotbar.lua
Normal 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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue