WorkStation: create WorkStation class, register test node & crafts, add work station UI

This commit is contained in:
Van
2026-02-07 22:14:07 +03:00
parent 169dd64bce
commit 66380fb873
7 changed files with 164 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
local modInfo = Mod.getInfo('smc__ui__work_station')
local require = modInfo.require
return require('WorkStationUI')

View File

@@ -0,0 +1,2 @@
name = smc__ui__work_station
depends = smc__core__formspec

View File

@@ -0,0 +1,40 @@
local modInfo = Mod.getInfo('smc__core__formspec')
local require = modInfo.require
---@type Formspec
local Formspec = require('Formspec')
---@class WorkStationUI
local WorkStationUI = {}
---@param items string[]
---@return string
function WorkStationUI:selectionCraftForm(items)
local listForm = Formspec:new({
size = {x=10, y=8},
})
local listFormItems = Formspec:new()
table.sort(items)
local w, h = 0, 0
---@param name string
for _, name in ipairs(items) do
listFormItems:itemImageButton(w, h, 2, 2, name, name..'::item_button')
w = w + 2
if w > 9 then
w = 0
h = h + 2
end
end
listForm:
scrollContainer(listFormItems, 0.5, 0.5, 8, 6, 'work_station:list_items', 'vertical'):
scrollbar(8, 0.5, 0.25, 7, 'vertical', 'work_station:list_items')
return listForm:toString()
end
return WorkStationUI