EmmyLua -> LuaLS

This commit is contained in:
Van
2026-06-16 17:50:29 +03:00
parent 60003eea73
commit 1799d6d32e
37 changed files with 135 additions and 314 deletions

View File

@@ -1,99 +0,0 @@
{
"codeAction": {
"insertSpace": false
},
"codeLens": {
"enable": true
},
"completion": {
"autoRequire": false,
"autoRequireFunction": "require",
"autoRequireNamingConvention": "keep",
"autoRequireSeparator": ".",
"callSnippet": false,
"enable": true,
"postfix": "@"
},
"diagnostics": {
"diagnosticInterval": 1,
"disable": [
"unnecessary-if",
"redefined-local"
],
"enable": true,
"enables": [],
"globals": [
"core",
"Smc",
"table",
"Events",
"VoxelArea",
"VoxelManip",
"vector",
"Ensure",
"string",
"string_utf8",
"Profiler"
],
"globalsRegex": []
},
"documentColor": {
"enable": true
},
"hint": {
"enable": true,
"indexHint": true,
"localHint": true,
"overrideHint": true,
"paramHint": true
},
"hover": {
"enable": true
},
"references": {
"enable": true,
"fuzzySearch": true,
"shortStringSearch": false
},
"resource": {
"paths": []
},
"runtime": {
"classDefaultCall": {
"forceNonColon": false,
"forceReturnSelf": false,
"functionName": ""
},
"extensions": [],
"frameworkVersions": [],
"requireLikeFunction": [],
"requirePattern": [],
"version": "LuaJIT"
},
"semanticTokens": {
"enable": true
},
"signature": {
"detailSignatureHelper": true
},
"strict": {
"arrayIndex": true,
"docBaseConstMatchBaseType": true,
"metaOverrideFileDefine": true,
"requirePath": false,
"typeCall": false
},
"workspace": {
"enableReindex": false,
"encoding": "utf-8",
"ignoreDir": [],
"ignoreGlobs": [],
"library": [
"util/ide-helper"
],
"moduleMap": [],
"preloadFileSize": 0,
"reindexDuration": 5000,
"workspaceRoots": []
}
}

36
.luarc.json Normal file
View File

@@ -0,0 +1,36 @@
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime.version": "LuaJIT",
"workspace.library": ["${workspaceFolder}/"],
"diagnostics.libraryFiles": "Enable",
"workspace.preloadFileSize": 500000,
"workspace.maxPreload": 500000,
"diagnostics.workspaceDelay": 2,
"hint.enable": true,
"diagnostics.enable": true,
"diagnostics.groupFileStatus": {
"ambiguity": "Any",
"duplicate": "Any",
"global": "Any",
"redefined": "Any",
"strict": "Any",
"type-check": "Any",
"unbalanced": "Any"
},
"diagnostics.disable": [
"inject-field"
],
"diagnostics.globals": [
"core",
"Smc",
"table",
"Events",
"VoxelArea",
"VoxelManip",
"vector",
"Ensure",
"string",
"string_utf8",
"Profiler"
]
}

View File

@@ -1,5 +1,4 @@
---@type Events.ControlsEvents local ControlsEvents = Smc.requireEvents('ControlsEvents') --[[@as Events.ControlsEvents]]
local ControlsEvents = Smc.requireEvents('ControlsEvents')
---@class Controls ---@class Controls
local Controls = {} local Controls = {}

View File

@@ -126,7 +126,7 @@ function BaseCraft:recipeToString(recipeIndex, mainList)
local recipeItem = ItemStack(itemName) local recipeItem = ItemStack(itemName)
recipeDesc = recipeDesc..('%s %s x%s\n'):format( recipeDesc = recipeDesc..('%s %s x%s\n'):format(
getCheckMaterialItem(recipeItem, recipeItem:get_count(), mainList), getCheckMaterialItem(recipeItem, recipeItem:get_count(), mainList),
core.strip_colors(recipeItem:get_definition()._title), core.strip_colors(Smc.getItemDefinition(recipeItem).settings._title),
recipeItem:get_count()) recipeItem:get_count())
else else
recipeDesc = recipeDesc..('%s any item from the group %s x%s\n'):format( recipeDesc = recipeDesc..('%s any item from the group %s x%s\n'):format(

View File

@@ -4,8 +4,7 @@ local coreChatSendPlayer, coreItemDrop = core.chat_send_player, core.item_drop
local require = Mod.getInfo('smc__core__craft_system').require local require = Mod.getInfo('smc__core__craft_system').require
---@type Events.ImmersiveCraftEvents local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents') --[[@as Events.ImmersiveCraftEvents]]
local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents')
---@type CraftSystem.BaseCraft ---@type CraftSystem.BaseCraft
local BaseCraft = require('CraftSystem.BaseCraft') local BaseCraft = require('CraftSystem.BaseCraft')
@@ -43,6 +42,8 @@ function ImmersiveCraft:new(name, def)
local StageClass = stageTypes[stageDef.type] local StageClass = stageTypes[stageDef.type]
stageDef.craftName = name stageDef.craftName = name
---@cast stageDef CraftSystem.ImmersiveCraftStage.TappingStageDef
local stage = StageClass:new(stageDef) local stage = StageClass:new(stageDef)
stagesByName[stageDef.name] = stage stagesByName[stageDef.name] = stage
@@ -60,8 +61,7 @@ function ImmersiveCraft:new(name, def)
if nextStageName == nil then if nextStageName == nil then
instance:endCraft(pos, player) instance:endCraft(pos, player)
else else
---@type ImmersiveWorkStation? local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
local workStation = Smc.getNodeSuperclassByPos(pos)
assert(workStation ~= nil) assert(workStation ~= nil)
local nextStage = instance.stagesByName[nextStageName] local nextStage = instance.stagesByName[nextStageName]
@@ -83,8 +83,7 @@ end
---@param amount integer ---@param amount integer
---@return boolean ---@return boolean
function ImmersiveCraft:startCraft(pos, player, amount) function ImmersiveCraft:startCraft(pos, player, amount)
---@type ImmersiveWorkStation? local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
local workStation = Smc.getNodeSuperclassByPos(pos)
assert(workStation ~= nil) assert(workStation ~= nil)
local meta = workStation:getMeta(pos) local meta = workStation:getMeta(pos)
@@ -118,8 +117,7 @@ end
---@param pos MapVector ---@param pos MapVector
---@param player Player ---@param player Player
function ImmersiveCraft:endCraft(pos, player) function ImmersiveCraft:endCraft(pos, player)
---@type ImmersiveWorkStation? local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
local workStation = Smc.getNodeSuperclassByPos(pos)
assert(workStation ~= nil) assert(workStation ~= nil)
local meta = workStation:getMeta(pos) local meta = workStation:getMeta(pos)
@@ -147,8 +145,7 @@ end
---Stop the crafting process and free up the workbench. ---Stop the crafting process and free up the workbench.
---@param pos MapVector ---@param pos MapVector
function ImmersiveCraft:abortCraft(pos) function ImmersiveCraft:abortCraft(pos)
---@type ImmersiveWorkStation? local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
local workStation = Smc.getNodeSuperclassByPos(pos)
assert(workStation ~= nil) assert(workStation ~= nil)
local meta = workStation:getMeta(pos) local meta = workStation:getMeta(pos)
@@ -171,6 +168,8 @@ function ImmersiveCraft:abortCraft(pos)
end end
---Returns a human-readable description of the crafting process. ---Returns a human-readable description of the crafting process.
---@param recipeIndex integer?
---@param mainList ItemStack[]?
---@return string ---@return string
function ImmersiveCraft:recipeToString(recipeIndex, mainList) function ImmersiveCraft:recipeToString(recipeIndex, mainList)
local recipeDesc = '' local recipeDesc = ''

View File

@@ -53,6 +53,8 @@ core.register_on_mods_loaded(function()
tableSort(crafts, function(a, b) tableSort(crafts, function(a, b)
if a.output < b.output then if a.output < b.output then
return true return true
else
return false
end end
end) end)
@@ -69,6 +71,8 @@ core.register_on_mods_loaded(function()
if outputA < outputB then if outputA < outputB then
return true return true
else
return false
end end
end) end)
end) end)

View File

@@ -1,7 +1,6 @@
local require = Mod.getInfo('smc__core__craft_system').require local require = Mod.getInfo('smc__core__craft_system').require
---@type Events.ImmersiveCraftEvents local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents') --[[@as Events.ImmersiveCraftEvents]]
local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents')
---@type CraftSystem.ImmersiveCraftNode ---@type CraftSystem.ImmersiveCraftNode
local ImmersiveCraftNode = require('CraftSystem.ImmersiveCraftNode') local ImmersiveCraftNode = require('CraftSystem.ImmersiveCraftNode')
@@ -68,7 +67,7 @@ local tappingNode = ImmersiveCraftNode:new({
---@param luaEntity CraftSystem.ImmersiveCraftNode.LuaTappingNode ---@param luaEntity CraftSystem.ImmersiveCraftNode.LuaTappingNode
get_staticdata = function(luaEntity) get_staticdata = function(luaEntity)
---@type CraftSystem.ImmersiveCraftStage.TappingNode.InitParams? ---@type CraftSystem.ImmersiveCraftStage.TappingNode.InitParams
local params = { local params = {
targetItem = luaEntity._item_name, targetItem = luaEntity._item_name,
craftName = luaEntity._craft_name, craftName = luaEntity._craft_name,

View File

@@ -5,8 +5,7 @@ local coreItemDrop = core.item_drop
local require = Mod.getInfo('smc__core__craft_system').require local require = Mod.getInfo('smc__core__craft_system').require
---@type Events.ImmersiveCraftEvents local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents') --[[@as Events.ImmersiveCraftEvents]]
local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents')
---@type CraftSystem.ImmersiveCraftStage ---@type CraftSystem.ImmersiveCraftStage
local ImmersiveCraftStage = require('CraftSystem.ImmersiveCraftStage') local ImmersiveCraftStage = require('CraftSystem.ImmersiveCraftStage')
@@ -41,8 +40,7 @@ local TappingStage = extend(ImmersiveCraftStage, {})
---@param def CraftSystem.ImmersiveCraftStage.TappingStageDef ---@param def CraftSystem.ImmersiveCraftStage.TappingStageDef
function TappingStage:new(def) function TappingStage:new(def)
---@type CraftSystem.ImmersiveCraftStage.TappingStage local instance = ImmersiveCraftStage:new(def) --[[@as CraftSystem.ImmersiveCraftStage.TappingStage]]
local instance = ImmersiveCraftStage:new(def)
instance.targetItem = def.targetItem instance.targetItem = def.targetItem
instance.clicksNeed = def.clicksNeed instance.clicksNeed = def.clicksNeed
instance.toolGroup = def.toolGroup instance.toolGroup = def.toolGroup
@@ -71,8 +69,7 @@ function TappingStage:new(def)
entityGUID = obj:get_guid() entityGUID = obj:get_guid()
} }
---@type ImmersiveWorkStation? local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
local workStation = Smc.getNodeSuperclassByPos(pos)
assert(workStation ~= nil) assert(workStation ~= nil)
local meta = workStation:getMeta(pos) local meta = workStation:getMeta(pos)
@@ -82,8 +79,7 @@ function TappingStage:new(def)
-- Registering the crafting stage process handler. -- Registering the crafting stage process handler.
-- Called when a player clicks on a crafting node (entity). -- Called when a player clicks on a crafting node (entity).
instance.processHandler = function(tappingStage, pos, player) instance.processHandler = function(tappingStage, pos, player)
---@type ImmersiveWorkStation? local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
local workStation = Smc.getNodeSuperclassByPos(pos)
assert(workStation ~= nil) assert(workStation ~= nil)
local meta = workStation:getMeta(pos) local meta = workStation:getMeta(pos)
@@ -104,8 +100,7 @@ function TappingStage:new(def)
-- Registering the crafting stage end handler. -- Registering the crafting stage end handler.
instance.endHandler = function(tappingStage, pos, player) instance.endHandler = function(tappingStage, pos, player)
---@type ImmersiveWorkStation? local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
local workStation = Smc.getNodeSuperclassByPos(pos)
assert(workStation ~= nil) assert(workStation ~= nil)
local meta = workStation:getMeta(pos) local meta = workStation:getMeta(pos)
@@ -113,7 +108,7 @@ function TappingStage:new(def)
local stageData = core.deserialize(meta:get_string('stage_data')) local stageData = core.deserialize(meta:get_string('stage_data'))
assert(stageData ~= nil) assert(stageData ~= nil)
local entity = Smc.getObjectByGUID(stageData.entityGUID) local entity = Smc.getObjectByGUID(stageData.entityGUID) --[[@as Entity?]]
assert(entity ~= nil, 'The entity for immersive crafting is nil.') assert(entity ~= nil, 'The entity for immersive crafting is nil.')
entity:remove() entity:remove()
@@ -123,9 +118,9 @@ function TappingStage:new(def)
-- Registering the aborting the crafting process handler. -- Registering the aborting the crafting process handler.
---@param tappingStage CraftSystem.ImmersiveCraftStage.TappingStage ---@param tappingStage CraftSystem.ImmersiveCraftStage.TappingStage
---@param pos MapVector
instance.abortHandler = function(tappingStage, pos) instance.abortHandler = function(tappingStage, pos)
---@type ImmersiveWorkStation? local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
local workStation = Smc.getNodeSuperclassByPos(pos)
assert(workStation ~= nil) assert(workStation ~= nil)
local meta = workStation:getMeta(pos) local meta = workStation:getMeta(pos)
@@ -140,7 +135,8 @@ function TappingStage:new(def)
local stageData = stageData local stageData = stageData
assert(stageData ~= nil, 'Immersive stage data is empty.') assert(stageData ~= nil, 'Immersive stage data is empty.')
local entity = Smc.getObjectByGUID(stageData.entityGUID) ---@type Entity?
local entity = Smc.getObjectByGUID(stageData.entityGUID) --[[@as Entity?]]
assert(entity ~= nil, 'The entity for immersive crafting is nil.') assert(entity ~= nil, 'The entity for immersive crafting is nil.')
entity:remove() entity:remove()

View File

@@ -69,6 +69,8 @@ core.register_on_mods_loaded(function()
tableSort(crafts, function(a, b) tableSort(crafts, function(a, b)
if a.output < b.output then if a.output < b.output then
return true return true
else
return false
end end
end) end)
@@ -85,6 +87,8 @@ core.register_on_mods_loaded(function()
if outputA < outputB then if outputA < outputB then
return true return true
else
return false
end end
end) end)
end) end)

View File

@@ -24,8 +24,7 @@ local function entityDefToLuantiDef(entityDef)
local s = entityDef.settings local s = entityDef.settings
local c = entityDef.callbacks or {} local c = entityDef.callbacks or {}
---@type EntityDefinition local luantiDef = tableMerge(s, c) --[[@as EntityDefinition]]
local luantiDef = tableMerge(s, c)
return luantiDef return luantiDef
end end
@@ -45,6 +44,7 @@ function Creature:new(entityDef)
local s = entityDef.settings local s = entityDef.settings
local c = entityDef.callbacks local c = entityDef.callbacks
assert(c ~= nil)
-- Add the short mod name prefix to the entity name. -- Add the short mod name prefix to the entity name.
if s._add_mod_name then if s._add_mod_name then
@@ -66,8 +66,7 @@ function Creature:new(entityDef)
initCustomFields.name = nil initCustomFields.name = nil
initCustomFields.object = nil initCustomFields.object = nil
---@type LuaEntity self = tableMerge(self, initCustomFields) --[[@as LuaEntity]]
self = tableMerge(self, initCustomFields)
-- If an initialization callback was specified for the entity, then we call it. -- If an initialization callback was specified for the entity, then we call it.
if c.on_activate ~= nil then if c.on_activate ~= nil then

View File

@@ -102,7 +102,7 @@ end
---@param pos MapVector ---@param pos MapVector
---@return ImmersiveWorkStation.MetaData ---@return ImmersiveWorkStation.MetaData
function ImmersiveWorkStation:getMeta(pos) function ImmersiveWorkStation:getMeta(pos)
return coreGetMeta(pos) return coreGetMeta(pos) --[[@as ImmersiveWorkStation.MetaData]]
end end
function ImmersiveWorkStation:showForm(pos, player) function ImmersiveWorkStation:showForm(pos, player)

View File

@@ -40,7 +40,7 @@ local RARITY_INDEX = {
---@class Item : Class ---@class Item : Class
---@field itemDef Item.ItemDefinition ---@field itemDef Item.ItemDefinition
---@field luantiDef ItemDefinition ---@field luantiDef ItemDefinition
---@field getType fun():string ---@field getType fun(self:Item):string
---@field defaultDef Item.ItemDefinition ---@field defaultDef Item.ItemDefinition
local Item = Class:extend({ local Item = Class:extend({
defaultDef = { defaultDef = {

View File

@@ -26,7 +26,7 @@ end
---@param itemDefs Item.ItemDefinition[]|Node.NodeDefinition[] List of nodes with parameters unique to them. ---@param itemDefs Item.ItemDefinition[]|Node.NodeDefinition[] List of nodes with parameters unique to them.
function ItemFactory:registerItems(itemDefs) function ItemFactory:registerItems(itemDefs)
---@param nodeDef Item.ItemDefinition | Node.NodeDefinition ---@param itemDef Item.ItemDefinition | Node.NodeDefinition
for _, itemDef in ipairs(itemDefs) do for _, itemDef in ipairs(itemDefs) do
itemDef = defMerge(itemDef, self.defaultDef, true) itemDef = defMerge(itemDef, self.defaultDef, true)
@@ -41,7 +41,7 @@ local defMerge = function(...)
return table.merge(...) return table.merge(...)
end end
---@param shortNodeDefs [string, (string[]|TileDefinition[])?][] Format list {{name, tiles}, {name, tiles}, ...} ---@param shortNodeDefs [string, (string[]|TileDefinition[]|nil)][] Format list {{name, tiles}, {name, tiles}, ...}
function ItemFactory:registerNodesByShortDef(shortNodeDefs) function ItemFactory:registerNodesByShortDef(shortNodeDefs)
for _, shortNodeDef in ipairs(shortNodeDefs) do for _, shortNodeDef in ipairs(shortNodeDefs) do
---@type Node.NodeDefinition ---@type Node.NodeDefinition

View File

@@ -181,7 +181,7 @@ end
function MapGen:isCavern(layer, x, y, z) function MapGen:isCavern(layer, x, y, z)
for _, cavern in ipairs(layer.cavernsList) do for _, cavern in ipairs(layer.cavernsList) do
if cavern.isRegional then if cavern.isRegional then
local inRegion, distance = self:pointInRegion2D(layer, cavern.name, v(x, y, z)) local inRegion, distance = self:pointInRegion2D(layer, cavern.name, v(x, y, z) --[[@as MapVector]])
if inRegion and distance ~= nil then if inRegion and distance ~= nil then
if cavern:isCavern(x, y, z, distance) then if cavern:isCavern(x, y, z, distance) then
@@ -394,7 +394,7 @@ function MapGen:findTriangle(layer, x, z, triangle)
return nil return nil
end end
isFound, triangle = self:isPointInTriangle(triangle, v(x, 0, z)) isFound, triangle = self:isPointInTriangle(triangle, v(x, 0, z) --[[@as MapVector]])
end end
return triangle return triangle
@@ -567,7 +567,6 @@ function MapGen:initCavernsNoise()
---@param layer MapGen.Layer ---@param layer MapGen.Layer
for _, layer in ipairs(self.layersList) do for _, layer in ipairs(self.layersList) do
---@param peak MapGen.Peak
for _, cavern in ipairs(layer.cavernsList) do for _, cavern in ipairs(layer.cavernsList) do
cavern:initNoise() cavern:initNoise()
end end
@@ -819,7 +818,7 @@ function MapGen:getFactors(layer, x, y, z)
end end
-- TODO: это сильно тормозит обычные чанки, но ускоряет те, что находятся за границей -- TODO: это сильно тормозит обычные чанки, но ускоряет те, что находятся за границей
if not self:pointInRegion2D(layer, 'triangles_boundary', v(x, y, z)) then if not self:pointInRegion2D(layer, 'triangles_boundary', v(x, y, z) --[[@as MapVector]]) then
return return
end end
@@ -833,7 +832,7 @@ function MapGen:getFactors(layer, x, y, z)
---@param triangle MapGen.Triangle ---@param triangle MapGen.Triangle
for _, triangle in ipairs(triangles) do for _, triangle in ipairs(triangles) do
if self:isPointInTriangle(triangle, v(x, 0, z)) then if self:isPointInTriangle(triangle, v(x, 0, z) --[[@as MapVector]]) then
local height = calcNoise2dValue('landscape', layer, triangle, x, y, z) local height = calcNoise2dValue('landscape', layer, triangle, x, y, z)
local temp = calcNoise2dValue('temp', layer, triangle, x, y, z) local temp = calcNoise2dValue('temp', layer, triangle, x, y, z)
local humidity = calcNoise2dValue('humidity', layer, triangle, x, y, z) local humidity = calcNoise2dValue('humidity', layer, triangle, x, y, z)

View File

@@ -19,8 +19,8 @@ local getInstance = Class.getInstance
---@field step integer? ---@field step integer?
---@field warpStrength number ---@field warpStrength number
--- ---
---@field getNoise fun():MapGen.Cavern.ValueNoise ---@field getNoise fun(self:MapGen.Cavern):MapGen.Cavern.ValueNoise
---@field initNoise fun() ---@field initNoise fun(self:MapGen.Cavern)
local Cavern = {} local Cavern = {}
---@alias MapGen.Cavern.NoiseParams {baseNoise:NoiseParams, xNoise?:NoiseParams, yNoise?:NoiseParams, zNoise?:NoiseParams} ---@alias MapGen.Cavern.NoiseParams {baseNoise:NoiseParams, xNoise?:NoiseParams, yNoise?:NoiseParams, zNoise?:NoiseParams}

View File

@@ -29,6 +29,7 @@ function Peak:new(def)
if def.groups == nil then if def.groups == nil then
_groups = {} _groups = {}
else else
---@type table<string, number>
_groups = def.groups _groups = def.groups
end end

View File

@@ -107,10 +107,9 @@ local function isAreaGenerated(pos1, pos2)
return true return true
end end
---@param pos MapPosition ---@param pos MapVector
function Tree:place(pos) function Tree:place(pos)
---@type MapVector, MapVector local pos1, pos2 = pos - v(16, 0, 16), pos + v(16, 80, 16) --[[@as MapVector]]
local pos1, pos2 = pos - v(16, 0, 16), pos + v(16, 80, 16)
if isAreaGenerated(pos1, pos2) then if isAreaGenerated(pos1, pos2) then
corePlaceSchematic(pos, self.path, getRotation(pos), nil, nil, 'place_center_x, place_center_z') corePlaceSchematic(pos, self.path, getRotation(pos), nil, nil, 'place_center_x, place_center_z')
@@ -120,7 +119,7 @@ function Tree:place(pos)
end end
---@param voxelManip VoxelManip ---@param voxelManip VoxelManip
---@param pos MapPosition ---@param pos MapVector
function Tree:placeOnVM(voxelManip, pos) function Tree:placeOnVM(voxelManip, pos)
local result = corePlaceSchematicOnVM(voxelManip, pos, self.path, getRotation(pos), nil, nil, 'place_center_x, place_center_z') local result = corePlaceSchematicOnVM(voxelManip, pos, self.path, getRotation(pos), nil, nil, 'place_center_x, place_center_z')

View File

@@ -181,7 +181,7 @@ function Triangle:getHeight(p1, p2, p3)
-- When * the dot product. -- When * the dot product.
local t = w:dot(v) / v:dot(v) local t = w:dot(v) / v:dot(v)
local posP = pos2 + v * t local posP = pos2 + v * t --[[@as IntegerVector]]
return Edge:new(p1, FakePeak:new(posP)) return Edge:new(p1, FakePeak:new(posP))
end end
@@ -211,7 +211,7 @@ function Triangle:getHeight2D(p1, p2, p3)
-- When * the dot product. -- When * the dot product.
local t = w:dot(v) / v:dot(v) local t = w:dot(v) / v:dot(v)
local posP = pos2 + v * t local posP = pos2 + v * t --[[@as IntegerVector]]
return Edge:new(p1, FakePeak:new(posP)) return Edge:new(p1, FakePeak:new(posP))
end end

View File

@@ -1,101 +0,0 @@
-- A method for converting an image with colored dots (pixels) into a Lua table grouped by color.
-- Author: @ssdaniel24 (github)
---Table with color as key and value is table with coordinates of dots. Note: coords begin from 1,1 (not 0,0).
---Example of table:
---```lua
---{
--- 'size': { h=256, w=256 },
--- '#fff': { {x=1,y=1}, {x=2,y=2}, ... },
--- '#ff0': { {x=3,y=3}, {x=4,y=4}, ... },
--- ...
---}
---```
---@alias ColoredDotsTable table<string,table>
---@param uintb string unsigned int bytes
---@return number
local function uintb2num(uintb)
local num = 0
local len = string.len(uintb)
for i = 1,len do
num = num*256 + string.byte(uintb, i)
end
return num
end
---Converts (scaling) 16-bit unsigned integer to 8-bit unsigned integer.
---Why? Because hex codes of colors are 8-bit: #ffffff -> ff = 256 (8 bit). Not 65536 (16 bit).
---@param num number 16-bit number
---@return number 8-bit number
local function uint16ToUint8(num)
return math.floor(num / 256)
end
---Converts given farbfeld image to ColoredDotsTable.
---Farbfeld format:
---```
---╔════════╤═════════════════════════════════════════════════════════╗
---║ Bytes │ Description ║
---╠════════╪═════════════════════════════════════════════════════════╣
---║ 8 │ 'farbfeld' magic value ║
---╟────────┼─────────────────────────────────────────────────────────╢
---║ 4 │ 32-Bit BE unsigned integer (width) ║
---╟────────┼─────────────────────────────────────────────────────────╢
---║ 4 │ 32-Bit BE unsigned integer (height) ║
---╟────────┼─────────────────────────────────────────────────────────╢
---║ [2222] │ 4x16-Bit BE unsigned integers [RGBA] / pixel, row-major ║
---╚════════╧═════════════════════════════════════════════════════════╝
---```
---[tools/farbfeld | suckless.org software that sucks less](https://tools.suckless.org/farbfeld/)
---@param filepath string image in farbfeld format
---@param backgroundColor string? ColorString, will be ignored while processing image. Default: `#000000FF`
---@return ColoredDotsTable
local function ff2luat(filepath, backgroundColor)
local file = io.open(filepath, 'rb')
if not file then error('Can\'t open farbfeld image: ' .. dump(filepath)) end
local ff = file:read('*a') -- binary!
file:close()
-- TODO: make it decompressing gzip format -> https://en.wikipedia.org/wiki/Gzip
-- I should skip 10 bytes in a beginning, read how many extra fields after it, skip them too, and skip last 8 bytes
-- (read wiki for information).
-- if filepath:sub(-3) == '.gz' then ff = core.decompress(ff, 'deflate') end
if not ff:sub(1,8) == 'farbfeld' then error('Not farbfeld image: ' .. dump(filepath)) end
if not backgroundColor then backgroundColor = '#000000FF' end
--HACK: normalizing colorstring for future string comparison ('#000' -> '#000000FF')
backgroundColor = Smc.fixColorString(backgroundColor)
---@type ColoredDotsTable
local dots = { size = { w = uintb2num(ff:sub(9,12)), h = uintb2num(ff:sub(13,16)) } }
local cursor
for i = 1,dots.size.h do
for j = 1,dots.size.w do
cursor = 16 + ((i-1)*dots.size.w + j-1)*8 + 1
local colorT = {
r = uint16ToUint8(uintb2num(ff:sub(cursor, cursor+1))),
g = uint16ToUint8(uintb2num(ff:sub(cursor+2,cursor+3))),
b = uint16ToUint8(uintb2num(ff:sub(cursor+4,cursor+5))),
a = uint16ToUint8(uintb2num(ff:sub(cursor+6,cursor+7)))
}
---@type string @ColorString
local color = core.colorspec_to_colorstring(colorT) or ''
if color ~= backgroundColor then
if not dots[color] then
dots[color] = {}
end
table.insert(dots[color], { x=j, y=i })
end
end
end
return dots
end
return ff2luat

View File

@@ -88,8 +88,8 @@ function Node:new(nodeDef)
registerStair(nodeDef) registerStair(nodeDef)
end end
---@type Node local instance = Item:new(nodeDef) --[[@as Node]]
local instance = Item:new(nodeDef)
return instance return instance
end end

View File

@@ -166,25 +166,25 @@ Callbacks.allow_metadata_inventory_take = nil
---Called after the actual action has happened, according to what was allowed. ---Called after the actual action has happened, according to what was allowed.
--- ---
---No return value. ---No return value.
---@type (fun(pos:MapVector, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): void)? ---@type (fun(pos:MapVector, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): any)?
Callbacks.on_metadata_inventory_move = nil Callbacks.on_metadata_inventory_move = nil
---Called after the actual action has happened, according to what was allowed. ---Called after the actual action has happened, according to what was allowed.
--- ---
---No return value. ---No return value.
---@type (fun(pos:MapVector, listname:string, index:number, stack:ItemStack, player:Player): void)? ---@type (fun(pos:MapVector, listname:string, index:number, stack:ItemStack, player:Player): any)?
Callbacks.on_metadata_inventory_put = nil Callbacks.on_metadata_inventory_put = nil
---Called after the actual action has happened, according to what was allowed. ---Called after the actual action has happened, according to what was allowed.
--- ---
---No return value. ---No return value.
---@type (fun(pos:MapVector, listname:string, index:number, stack:ItemStack, player:Player): void)? ---@type (fun(pos:MapVector, listname:string, index:number, stack:ItemStack, player:Player): any)?
Callbacks.on_metadata_inventory_take = nil Callbacks.on_metadata_inventory_take = nil
---If defined, called when an explosion touches the node, instead of ---If defined, called when an explosion touches the node, instead of
---removing the node. ---removing the node.
---* `intensity`: 1.0 = mid range of regular TNT. ---* `intensity`: 1.0 = mid range of regular TNT.
---@type (fun(pos:MapVector, intensity:number): void)? ---@type (fun(pos:MapVector, intensity:number): any)?
Callbacks.on_blast = nil Callbacks.on_blast = nil
return Callbacks return Callbacks

View File

@@ -76,7 +76,7 @@ function ProcessingContainerStation:new(def, nodesDef)
callbacks.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) callbacks.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
oldCallback(pos, node, clicker, itemstack, pointed_thing) oldCallback(pos, node, clicker, itemstack, pointed_thing)
instance:showForm(pos, clicker) instance:showForm(pos, clicker --[[@as Player]])
end end
oldCallback = callbacks.on_metadata_inventory_move or function(...) end oldCallback = callbacks.on_metadata_inventory_move or function(...) end
@@ -249,8 +249,7 @@ function ProcessingContainerStation:pushFuelStation( meta, pos)
return return
end end
---@type ProcessingFuelStation? local fuelStation = Smc.getNodeSuperclassByPos(fuelPos) --[[@as ProcessingFuelStation?]]
local fuelStation = Smc.getNodeSuperclassByPos(fuelPos)
assert(fuelStation ~= nil) assert(fuelStation ~= nil)
if fuelStation.fuelGroup ~= self.fuelGroup then if fuelStation.fuelGroup ~= self.fuelGroup then
@@ -307,10 +306,8 @@ local tab = function(self, playerName, tabType)
local pos = self:getContex(playerName, 'node_tab_pos') local pos = self:getContex(playerName, 'node_tab_pos')
local inventoryLocation = ('nodemeta:%s,%s,%s'):format(pos.x, pos.y, pos.z) local inventoryLocation = ('nodemeta:%s,%s,%s'):format(pos.x, pos.y, pos.z)
---@type ProcessingContainerStation.MetaData local meta = core.get_meta(pos) --[[@as ProcessingContainerStation.MetaData]]
local meta = core.get_meta(pos) local fuelMeta = core.get_meta(pos - vector.new(0, 1, 0)) --[[@as ProcessingFuelStation.MetaData]]
---@type ProcessingFuelStation.MetaData
local fuelMeta = core.get_meta(pos - vector.new(0, 1, 0))
form form
:image(0, 0, 11, 9, 'player_inventory_tab_background.png') :image(0, 0, 11, 9, 'player_inventory_tab_background.png')

View File

@@ -96,7 +96,7 @@ function ProcessingFuelStation:new(def, nodesDef)
callbacks.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) callbacks.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
oldCallback(pos, node, clicker, itemstack, pointed_thing) oldCallback(pos, node, clicker, itemstack, pointed_thing)
instance:showForm(pos, clicker) instance:showForm(pos, clicker --[[@as Player]])
end end
oldCallback = callbacks.on_metadata_inventory_move or function(...) end oldCallback = callbacks.on_metadata_inventory_move or function(...) end
@@ -312,8 +312,7 @@ function ProcessingFuelStation:pushContainerStation(meta, pos)
return return
end end
---@type ProcessingContainerStation? local containerStation = Smc.getNodeSuperclassByPos(containerPos) --[[@as ProcessingContainerStation?]]
local containerStation = Smc.getNodeSuperclassByPos(containerPos)
assert(containerStation ~= nil) assert(containerStation ~= nil)
if containerStation.fuelGroup ~= self.fuelGroup then if containerStation.fuelGroup ~= self.fuelGroup then
@@ -326,7 +325,6 @@ end
---@param pos MapVector ---@param pos MapVector
---@param elapsed number ---@param elapsed number
---@param node NodeTable ---@param node NodeTable
---@param elapsed number
---@return boolean? ---@return boolean?
function ProcessingFuelStation:onTimer(pos, elapsed, node, timeout) function ProcessingFuelStation:onTimer(pos, elapsed, node, timeout)
local meta = self:getMeta(pos) local meta = self:getMeta(pos)
@@ -369,8 +367,7 @@ local tab = function(self, playerName, tabType)
local pos = self:getContex(playerName, 'node_tab_pos') local pos = self:getContex(playerName, 'node_tab_pos')
local inventoryLocation = ('nodemeta:%s,%s,%s'):format(pos.x, pos.y, pos.z) local inventoryLocation = ('nodemeta:%s,%s,%s'):format(pos.x, pos.y, pos.z)
---@type ProcessingFuelStation.MetaData local meta = core.get_meta(pos) --[[@as ProcessingFuelStation.MetaData]]
local meta = core.get_meta(pos)
form form
:image(0, 0, 11, 9, 'player_inventory_tab_background.png') :image(0, 0, 11, 9, 'player_inventory_tab_background.png')
@@ -404,8 +401,7 @@ core.register_abm({
nodenames = {'processing_fuel_station:test_processing_node'}, nodenames = {'processing_fuel_station:test_processing_node'},
---@param pos MapVector ---@param pos MapVector
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
---@type ProcessingFuelStation.MetaData local meta = core.get_meta(pos) --[[@as ProcessingFuelStation.MetaData]]
local meta = core.get_meta(pos)
if meta:get_float("remaining_fuel") > 0 then if meta:get_float("remaining_fuel") > 0 then
core.add_particlespawner({ core.add_particlespawner({
amount = 10, amount = 10,

View File

@@ -62,7 +62,7 @@ function ProcessingStation:new(def, nodesDef)
callbacks.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) callbacks.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
oldCallback(pos, node, clicker, itemstack, pointed_thing) oldCallback(pos, node, clicker, itemstack, pointed_thing)
instance:showForm(pos, clicker) instance:showForm(pos, clicker --[[@as Player]])
end end
oldCallback = callbacks.on_metadata_inventory_move or function(...) end oldCallback = callbacks.on_metadata_inventory_move or function(...) end
@@ -170,8 +170,7 @@ local tab = function(self, playerName, tabType)
local pos = self:getContex(playerName, 'node_tab_pos') local pos = self:getContex(playerName, 'node_tab_pos')
local inventoryLocation = ('nodemeta:%s,%s,%s'):format(pos.x, pos.y, pos.z) local inventoryLocation = ('nodemeta:%s,%s,%s'):format(pos.x, pos.y, pos.z)
---@type ProcessingStation.MetaData local meta = core.get_meta(pos) --[[@as ProcessingStation.MetaData]]
local meta = core.get_meta(pos)
form form
:image(0, 0, 11, 9, 'player_inventory_tab_background.png') :image(0, 0, 11, 9, 'player_inventory_tab_background.png')

View File

@@ -14,8 +14,8 @@ function Tool:new(ToolDef)
ToolDef.settings._type = 'tool' ToolDef.settings._type = 'tool'
---@type Tool local instance = Item:new(ToolDef) --[[@as Tool]]
local instance = Item:new(ToolDef)
return instance return instance
end end

View File

@@ -752,8 +752,7 @@ mapGenerator:registerBiome('midgard', 'green_meadow', {
if value > 8 then if value > 8 then
if x % 10 == 0 and z % 10 == 0 then if x % 10 == 0 and z % 10 == 0 then
---@type MapVector local pos = v(x, y+1, z) --[[@as MapVector]]
local pos = v(x, y+1, z)
mapGenerator:getTree('test_tree'):placeOnVM(voxelManip, pos) mapGenerator:getTree('test_tree'):placeOnVM(voxelManip, pos)
end end
end end

View File

@@ -89,7 +89,7 @@ core.register_chatcommand('get_missing_locale', {
privs = {server = true}, privs = {server = true},
description = '{short_mod_name:string?, lang_codes:string[]?}', description = '{short_mod_name:string?, lang_codes:string[]?}',
func = function(name, paramsStr) func = function(name, paramsStr)
local params = core.deserialize('return '..paramsStr or '{}') local params = core.deserialize(('return '..paramsStr) or '{}')
if params == nil then if params == nil then
return false return false

View File

@@ -1,8 +1,8 @@
---@alias Events.Callback fun(...) ---@alias Events.Callback fun(...)
---@alias Events.Type ---@alias Events.Type
--- 'ControlsEvents'| ---|'ControlsEvents'
--- 'ImmersiveCraftEvents' ---|'ImmersiveCraftEvents'
---@class Events : Class ---@class Events : Class
---@field registeredEvents table<string, Events.Callback[]> ---@field registeredEvents table<string, Events.Callback[]>

View File

@@ -2,7 +2,7 @@
---Each instance of such a class registers one or more nodes and implements their logic. ---Each instance of such a class registers one or more nodes and implements their logic.
--- ---
---**Note**: An instance is static for all nodes it registers. ---**Note**: An instance is static for all nodes it registers.
---@interface NodeSuperClass ---@class NodeSuperClass
---@type table<string, NodeSuperClass> ---@type table<string, NodeSuperClass>
local nodeSuperClasses = {} local nodeSuperClasses = {}

View File

@@ -40,7 +40,7 @@ end
---@param itemName ItemStack|ItemStackString ---@param itemName ItemStack|ItemStackString
---@return Item.ItemDefinition|Node.NodeDefinition ---@return Item.ItemDefinition|Node.NodeDefinition
function Smc.getItemDefinition(itemName) function Smc.getItemDefinition(itemName)
if type(itemName) == 'table' or type(itemName) == 'userdata' then if type(itemName) ~= 'string' then
itemName = itemName:get_name() itemName = itemName:get_name()
end end

View File

@@ -1,11 +1,9 @@
local math = math
---Limiting the value by minimum and maximum value. ---Limiting the value by minimum and maximum value.
---@param value number The value to be limited. ---@param value number The value to be limited.
---@param min number Minimum limit. ---@param min number Minimum limit.
---@param max number Maximum limit. ---@param max number Maximum limit.
---@return number ---@return number
math.clamp = function(value, min, max) function math.clamp(value, min, max)
return math.min(math.max(value, min), max) return math.min(math.max(value, min), max)
end end

View File

@@ -58,7 +58,6 @@ end
function table.contains(t, value) function table.contains(t, value)
ensureArgType(t, 'table', 1, 'table.contains') ensureArgType(t, 'table', 1, 'table.contains')
---@diagnostic disable-next-line: param-type-not-match
return tableKeyOf(t, value) ~= nil return tableKeyOf(t, value) ~= nil
end end
@@ -415,7 +414,7 @@ end
---@generic value any ---@generic value any
---@param list value[] ---@param list value[]
---@param value value ---@param value value
---@param value[] ---@return value[]
function table.remove_value(list, value) function table.remove_value(list, value)
local index = table.indexof(list, value) local index = table.indexof(list, value)
while index ~= -1 do while index ~= -1 do

View File

@@ -48,16 +48,16 @@ local function getFormSpecString(self, playerName, isSelect)
if isSelect then if isSelect then
---@type ItemStackString ---@type ItemStackString
local item = self:getContex(playerName, 'select_item') local item = self:getContex(playerName, 'select_item')
local itemDef = core.registered_items[item] local itemSettings = Smc.getItemDefinition(item).settings
listForm listForm
:itemImage(11, 0.5, 2, 2, item) :itemImage(11, 0.5, 2, 2, item)
:areaLabel(11, 4.5, 4, 1, 'Add to inventory:') :areaLabel(11, 4.5, 4, 1, 'Add to inventory:')
:button(11, 5, 3, 1, 'admin_commands:list_add_item', '1') :button(11, 5, 3, 1, 'admin_commands:list_add_item', '1')
:button(14, 5,3, 1, 'admin_commands:list_add_item', ''..tostring(itemDef.stack_max)) :button(14, 5,3, 1, 'admin_commands:list_add_item', ''..tostring(itemSettings.stack_max))
:areaLabel(14.5, 0.5, 6, 4, :areaLabel(14.5, 0.5, 6, 4,
item..'\n\n'.. item..'\n\n'..
(itemDef._title or itemDef.description)..'\n'.. (itemSettings._title or itemSettings.description)..'\n'..
(itemDef._description or '')) (itemSettings._description or ''))
end end
return listForm:toString() return listForm:toString()

View File

@@ -240,17 +240,17 @@ end
---Context keys for the `PlayerInventoryUI` class. ---Context keys for the `PlayerInventoryUI` class.
---@alias PlayerInventoryUI.ContexKey ---@alias PlayerInventoryUI.ContexKey
--- 'compact_mode'| ---|'compact_mode'
--- 'node_tab_pos'| ---|'node_tab_pos'
--- 'node_tab'| ---|'node_tab'
--- ---
--- 'left_tab_name'| ---|'left_tab_name'|
--- 'right_tab_name'| ---|'right_tab_name'|
--- ---
--- 'left_craft_tab_craft_data'| ---|'left_craft_tab_craft_data'|
--- 'right_craft_tab_craft_data'| ---|'right_craft_tab_craft_data'|
--- 'left_node_tab_craft_data'| ---|'left_node_tab_craft_data'|
--- 'right_node_tab_craft_data' ---|'right_node_tab_craft_data'
---@class PlayerInventoryUI : BaseUI ---@class PlayerInventoryUI : BaseUI
@@ -265,7 +265,6 @@ local PlayerInventoryUI = BaseUI:new('', getFormSpecString, false)
---@param tabName 'craft_tab'|'node_tab' ---@param tabName 'craft_tab'|'node_tab'
---@return PlayerInventoryUI.CraftTabData ---@return PlayerInventoryUI.CraftTabData
function PlayerInventoryUI:getTabCraftData(playerName, tabType, tabName) function PlayerInventoryUI:getTabCraftData(playerName, tabType, tabName)
---@diagnostic disable-next-line: param-type-not-match
---@type PlayerInventoryUI.CraftTabData ---@type PlayerInventoryUI.CraftTabData
local craftTabData = self:getContex(playerName, tabType..'_'..tabName..'_craft_data') local craftTabData = self:getContex(playerName, tabType..'_'..tabName..'_craft_data')
@@ -277,7 +276,6 @@ end
---@param tabName 'craft_tab'|'node_tab' ---@param tabName 'craft_tab'|'node_tab'
---@param data PlayerInventoryUI.CraftTabData ---@param data PlayerInventoryUI.CraftTabData
function PlayerInventoryUI:setTabCraftData(playerName, tabType, tabName, data) function PlayerInventoryUI:setTabCraftData(playerName, tabType, tabName, data)
---@diagnostic disable-next-line: param-type-not-match
self:setContex(playerName, tabType..'_'..tabName..'_craft_data', data) self:setContex(playerName, tabType..'_'..tabName..'_craft_data', data)
end end
@@ -716,7 +714,7 @@ core.register_allow_player_inventory_action(function(player, action, inventory,
-- Equipment items will automatically place themselves in their slots -- Equipment items will automatically place themselves in their slots
-- when you hold down the shift key. -- when you hold down the shift key.
if inventoryInfo.to_list == 'listring_equip' then if inventoryInfo.to_list == 'listring_equip' then
return equipListring(player, inventory, inventoryInfo.from_list, inventoryInfo.from_index) return equipListring(player --[[@as Player]], inventory, inventoryInfo.from_list, inventoryInfo.from_index)
end end
-- Checking if a slot is an equipment slot. -- Checking if a slot is an equipment slot.

View File

@@ -26,7 +26,7 @@ local function getBagTab(self, playerName, tabType)
BagLists BagLists
:image(0.5, 0, 9.875, (lines)*1.25+1, background) :image(0.5, 0, 9.875, (lines)*1.25+1, background)
:itemImage(0.5625, 0.0625, 1, 1, bag:get_name()) :itemImage(0.5625, 0.0625, 1, 1, bag:get_name())
:label(1.7625, 0.5, bag:get_definition()._title or '') :label(1.7625, 0.5, Smc.getItemDefinition(bag).settings._title or '')
:list('current_player', 'inventory_back', 0.5625, 1.25, 8, 4) :list('current_player', 'inventory_back', 0.5625, 1.25, 8, 4)
containerHeight = containerHeight + lines * 1.25 + 1 containerHeight = containerHeight + lines * 1.25 + 1
@@ -43,7 +43,7 @@ local function getBagTab(self, playerName, tabType)
BagLists BagLists
:image(0.5, containerHeight, 9.875, (lines)*1.25+1, background) :image(0.5, containerHeight, 9.875, (lines)*1.25+1, background)
:itemImage(0.5625, containerHeight + 0.0625, 1, 1, bag:get_name()) :itemImage(0.5625, containerHeight + 0.0625, 1, 1, bag:get_name())
:label(1.7625, containerHeight + 0.5, bag:get_definition()._title or '') :label(1.7625, containerHeight + 0.5, Smc.getItemDefinition(bag).settings._title or '')
:list('current_player', 'inventory_left_thigh', 0.5625, containerHeight + 1.25, 8, 4) :list('current_player', 'inventory_left_thigh', 0.5625, containerHeight + 1.25, 8, 4)
containerHeight = containerHeight + lines * 1.25 + 1 containerHeight = containerHeight + lines * 1.25 + 1
@@ -60,7 +60,7 @@ local function getBagTab(self, playerName, tabType)
BagLists BagLists
:image(0.5, containerHeight, 9.875, (lines)*1.25+1, background) :image(0.5, containerHeight, 9.875, (lines)*1.25+1, background)
:itemImage(0.5625, containerHeight + 0.0625, 1, 1, bag:get_name()) :itemImage(0.5625, containerHeight + 0.0625, 1, 1, bag:get_name())
:label(1.7625, containerHeight + 0.5, bag:get_definition()._title or '') :label(1.7625, containerHeight + 0.5, Smc.getItemDefinition(bag).settings._title or '')
:list('current_player', 'inventory_right_thigh', 0.5625, containerHeight + 1.25, 8, 4) :list('current_player', 'inventory_right_thigh', 0.5625, containerHeight + 1.25, 8, 4)
containerHeight = containerHeight + lines * 1.25 + 1 containerHeight = containerHeight + lines * 1.25 + 1

View File

@@ -34,15 +34,15 @@ local function getFormSpecString(self, playerName, isSelect)
if isSelect then if isSelect then
local stage = craft.stagesByName[craft.startStageName] local stage = craft.stagesByName[craft.startStageName]
local outputDef = core.registered_nodes[craft.output] local outputSettings = Smc.getItemDefinition(craft.output).settings
listForm listForm
:itemImage(9, 0.5, 2, 2, craft.output) :itemImage(9, 0.5, 2, 2, craft.output)
:areaLabel(9, 6, 2, 1, 'Start crafting:') :areaLabel(9, 6, 2, 1, 'Start crafting:')
:button(9, 6.5, 3, 1, 'work_station:start_craft', 'x1') :button(9, 6.5, 3, 1, 'work_station:start_craft', 'x1')
:button(12, 6.5,3, 1, 'work_station:start_craft', 'x10') :button(12, 6.5,3, 1, 'work_station:start_craft', 'x10')
:areaLabel(11.5, 0.5, 4, 4, :areaLabel(11.5, 0.5, 4, 4,
outputDef._title..'\n'.. outputSettings._title..'\n'..
outputDef._description) outputSettings._description)
:areaLabel(9, 2.5, 6, 4, 'Craft description:'..'\n'..craft:toString()) :areaLabel(9, 2.5, 6, 4, 'Craft description:'..'\n'..craft:toString())
end end