adminCommands: update /list command

This commit is contained in:
Van
2026-02-27 21:55:34 +03:00
parent c7cfe26335
commit 8b55ccff72
9 changed files with 166 additions and 113 deletions

View File

@@ -0,0 +1,68 @@
local modInfo = Mod.getInfo('smc__core__formspec')
local require = modInfo.require
---@type AdminListUI
local AdminListUI = Mod.getInfo('smc__ui__admin_list').require('AdminListUI')
core.register_chatcommand('list', {
privs = {server = true},
func = function(name, param)
local player = core.get_player_by_name(name)
AdminListUI:showForm(name, false)
return true, ''
end
})
AdminListUI:registerOnFormFieldActionMatch('%S+::item_button',function(player, fieldName, fieldValue)
---@type ItemStackString?
local stack = string.match(fieldName, '(%S+)::item_button')
if stack == nil then
return
end
local playerName = player:get_player_name()
AdminListUI:setContex(playerName, 'select_item', stack)
AdminListUI:showForm(playerName, true)
end)
AdminListUI:registerOnFormFieldAction('admin_commands:list_add_item', function(player, fieldName, fieldValue)
---@type InvRef
local inv = player:get_inventory()
local playerName = player:get_player_name()
local stack = AdminListUI:getContex(playerName, 'select_item')
stack = ItemStack(stack)
stack:set_count(fieldValue)
if inv:room_for_item('main', stack) then
inv:add_item('main', stack)
end
end)
core.register_on_joinplayer(function(player, last_login)
player:set_sky({
sky_color = {
day_sky = '#FAE6E0',
day_horizon = '#E7A985',
},
type = 'regular',
})
player:set_lighting({
shadows = { intensity = 0.33 },
volumetric_light = { strength = 0.45 },
exposure = {
luminance_min = -3.5,
luminance_max = -2.5,
exposure_correction = 0.35,
speed_dark_bright = 1500,
speed_bright_dark = 700,
},
saturation = 1.0,
})
end)

View File

@@ -0,0 +1,2 @@
name = smc__game__admin_commands
depends = smc__system__system_loader, smc__ui__admin_list