Add leafs & fix list command

This commit is contained in:
Van
2026-02-22 22:01:22 +03:00
parent 745eaa8569
commit e0b9024458
6 changed files with 90 additions and 146 deletions

View File

@@ -4,43 +4,47 @@ local require = modInfo.require
---@type Formspec
local Formspec = require('Formspec')
local listForm = Formspec:new({
size = {x=21, y=12},
})
local function getForm()
local listForm = Formspec:new({
size = {x=21, y=12},
})
listForm:list('current_player', 'main', 10.5, 6.5, 8, 4)
listForm:list('current_player', 'main', 10.5, 6.5, 8, 4)
local listFormItems = Formspec:new()
local listFormItems = Formspec:new()
local items = table.get_keys(core.registered_nodes)
table.sort(items)
local w, h = 0, 0
local items = table.get_keys(core.registered_nodes)
table.sort(items)
local w, h = 0, 0
---@param name string
for _, name in ipairs(items) do
listFormItems:itemImageButton(w, h, 1, 1, name, name..'::item_button')
---@param name string
for _, name in ipairs(items) do
listFormItems:itemImageButton(w, h, 1, 1, name, name..'::item_button')
w = w + 1
w = w + 1
if w > 9 then
w = 0
h = h + 1
if w >= 9 then
w = 0
h = h + 1
end
end
--listFormItems:list('current_player', 'main', 0, 0, 1, 32)
listForm:
scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical'):
scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items')
return listForm
end
--listFormItems:list('current_player', 'main', 0, 0, 1, 32)
listForm:
scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical'):
scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items')
core.register_chatcommand('list', {
privs = {server = true},
func = function(name, param)
local player = core.get_player_by_name(name)
core.show_formspec(name, 'admin_commands:list_form', listForm:toString())
core.show_formspec(name, 'admin_commands:list_form', getForm():toString())
return true, ''
end

View File

@@ -1,2 +1,2 @@
name = smc__core__admin_commands
depends = smc__system__system_loader, smc__core__formspec, smc__core__item
depends = smc__system__system_loader, smc__core__formspec