57 Commits

Author SHA1 Message Date
c3defaaa15 Update ide-helper 2026-11-17 22:05:44 +03:00
7ccaea2ed0 Math: end-space 2026-11-17 21:47:14 +03:00
c96bb2c0bc Class: minor formal changes 2026-11-17 21:35:05 +03:00
9fa3a0aff7 PlayerInventoryUI: item list count button update 2026-11-17 21:29:34 +03:00
e540107876 Mod: .getInfo() -> :getInfo() 2026-11-13 17:43:26 +03:00
1e91290b02 HelperLib: rename load() -> loadFile(), add doFile() 2026-11-13 17:06:08 +03:00
2243ed7532 HelperLib: load() update 2026-11-11 21:54:44 +03:00
20ebf5ad75 PlayerInventoryUI: end-spaces 2026-11-11 21:31:17 +03:00
1fe3200692 PlayerInventoryUI: separate action handling 2026-11-11 21:26:56 +03:00
24932b5d2e Mod & Require: add load function 2026-11-11 21:01:59 +03:00
af0b7c8beb check for negative quantities in crafting functions 2026-11-11 20:31:41 +03:00
ba8dad4798 bump commit 2026-11-09 22:15:33 +03:00
c2e16834d8 Add Smc.putOrDrop function 2026-11-09 21:30:23 +03:00
2d3bdf4d02 PlayerInventoryUI: remove TODO 2026-11-09 21:08:44 +03:00
841d269494 inventory: remove TODO 2026-11-09 21:07:05 +03:00
ced1397c76 Node: minor groups fix 2026-11-08 20:50:13 +03:00
56a9388676 ide-helper update 2026-11-08 20:49:47 +03:00
5d3e7b3620 adminCommands: update /list command - use PlayerInventoryUI 2026-11-05 20:59:51 +03:00
f995397f28 PlayerInventoryUI: add admin list tab, some changes, rename textures and minor refactoring 2026-11-05 20:59:04 +03:00
9566e0edde CraftSystem: BaseCraftHandler: use Smc.matchItemDescription() 2026-11-05 20:56:36 +03:00
316d2cac3b HelperLib: add matchItemDescription() function 2026-11-05 20:55:05 +03:00
3da8c3a27c update .luarc.json 2026-10-18 21:25:02 +03:00
266d44eca8 PlayerInventoryUI: modification of tab-switching button creation 2026-10-04 22:34:55 +03:00
d82cd28407 Formspec: new method imageButtonRow 2026-10-04 22:27:47 +03:00
02f7ca2894 MapGenerator: add peat_bog (Багно) biome. Add allwhere & marentine tree-schemes 2026-10-02 21:44:59 +03:00
7ef96bd434 AdminListUI: fix non-smc select items 2026-10-02 21:35:12 +03:00
26a73117a9 MapGen: fix trees replace trunks 2026-10-02 21:33:07 +03:00
87e5304acd HelperLib: new getItemDefinitionOrNil function 2026-10-02 21:32:00 +03:00
600c83ea04 wood: change braches registration 2026-10-02 21:30:53 +03:00
e8f547e98b soils: add new registrations, remove unused code 2026-10-02 21:29:59 +03:00
c7d2b94603 plants: update plants mod: add new, save & remove debug 2026-10-02 21:27:45 +03:00
934a8a8e83 adminCommands: add set_param2 command 2026-09-23 21:12:05 +03:00
50572e4c6b update ide-helper 2026-09-20 21:46:47 +03:00
b10f5c314a MapGen: fix water generation 2026-09-20 21:16:12 +03:00
a90c5a31d7 Fix mod depenses 2026-09-10 20:28:24 +03:00
f375e0aa19 MapGen: add MapGen:random() method 2026-09-09 22:02:35 +03:00
8c482b9cac Update ide-helper 2026-09-08 22:34:13 +03:00
92516f7ec4 Update ide-helper 2026-09-05 21:46:45 +03:00
a4249091e0 MapGen: minor fix 2026-09-05 21:35:41 +03:00
5a138cdf68 mapGeneration: rename tarion -> videre 2026-09-05 21:30:30 +03:00
bf4966afe4 mapGeneration: add end-space 2026-09-05 21:25:34 +03:00
f586121b12 mapGeneration: remove old maps 2026-09-05 21:24:40 +03:00
613e7a9c93 mapGeneration: update noise params 2026-09-05 21:22:25 +03:00
7a06e7fffb MapGenerator: new map 2026-08-30 18:19:05 +03:00
582658d437 Fix some mod depenses 2026-08-30 17:38:36 +03:00
4fcb15424e Update ide-helper 2026-08-14 22:16:17 +03:00
97711eccb8 mapGenerator: minor changes 2026-08-14 21:31:51 +03:00
c380638166 soils: idk, refactoring? Experements? 2026-08-14 21:31:25 +03:00
ccb89d2990 sands: minor changes 2026-08-14 21:30:05 +03:00
fe8e72cdde rocks: new rocks, remove old rocks 2026-08-14 21:29:09 +03:00
87a68f056e update luanti-ide-helper 2026-08-14 21:16:41 +03:00
6eac20e4f5 PlayerInventoryUI: resprite inventory 2026-08-13 21:03:29 +03:00
4210248343 Add ores mod 2026-08-02 19:05:50 +03:00
441fbb8323 Add sands mod 2026-08-02 19:04:35 +03:00
467d251681 Add clays mod 2026-08-02 19:03:55 +03:00
a9c5e54b00 Node: minor change 2026-07-23 19:00:09 +03:00
6935673be7 Add new admin command /create_locale 2026-07-23 18:59:39 +03:00
131 changed files with 2258 additions and 12116 deletions

View File

@@ -46,5 +46,6 @@
"unbalanced": "Any"
}
},
"completion.callSnippet": "Both"
"completion.callSnippet": "Both",
"completion.workspaceWord":false
}

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__base_processing_station')
local modInfo = Mod:getInfo('smc__core__base_processing_station')
local require = modInfo.require
return require('BaseProcessingStation')

View File

@@ -1,2 +1,2 @@
name = smc__core__base_processing_station
depends = smc__core__craft_system, smc__core__node
depends = smc__core__craft_system, smc__core__node, smc__ui__player_inventory

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__base_ui')
local modInfo = Mod:getInfo('smc__core__base_ui')
local require = modInfo.require
return require('BaseUI')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__controls')
local modInfo = Mod:getInfo('smc__core__controls')
local require = modInfo.require
return require('Controls')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__craft_system')
local modInfo = Mod:getInfo('smc__core__craft_system')
local require = modInfo.require
return require('CraftSystem')

View File

@@ -1,6 +1,6 @@
local tableJoin = table.join
local modInfo = Mod.getInfo('smc__core__craft_system')
local modInfo = Mod:getInfo('smc__core__craft_system')
local require = modInfo.require
---@type CraftSystem.PrimitiveCraftHandler
@@ -205,9 +205,19 @@ end
---@return boolean check true if craft can be produced
---@return ItemStack[] materialStacks list of itemStacks for crafting
function CraftSystem:checkPossiblePlayerInventoryCrafting(player, craft, recipeIndex, count)
local OutputStack = ItemStack(craft.output)
if count <= 0 then
Logger.warningLog('`CraftSystem:checkPossiblePlayerInventoryCrafting()`: param `count` <= 0. '..
'Was force-reset to `1`. '..
'Info: value: `%s`, player: `%s`, craft: `%s`',
count, player:get_player_name(), craft.name
)
count = 1
end
local inventory = player:get_inventory()
local OutputStack = ItemStack(craft.output)
OutputStack:set_count(OutputStack:get_count() * count)
local materialStacks, materialGroups = getMaterials(craft, recipeIndex, count)

View File

@@ -3,7 +3,7 @@ local assert, pairs, ipairs = assert, pairs, ipairs
local tableInsert, tableSort, tableJoin = table.insert, table.sort, table.join
local stringMatch, stringLower = string.match, string_utf8.lower
local require = Mod.getInfo('smc__core__craft_system').require
local require = Mod:getInfo('smc__core__craft_system').require
---@type CraftSystem.BaseCraftHandler.PlayerCraftsCache
local PlayerCraftsCache = require('CraftSystem.BaseCraftHandler.PlayerCraftsCache')
@@ -239,14 +239,7 @@ local function getMathedCrafts(crafts, pattern)
local matchedCrafts = {}
for _, craft in ipairs(crafts) do
local outputItem = ItemStack(craft.output)
local itemSettings = Smc.getItemDefinition(outputItem).settings
local ruName = stringLower(core.get_translated_string('ru', itemSettings._title))
local enName = stringLower(core.get_translated_string('en', itemSettings._title))
if stringMatch(outputItem:get_name(), pattern) or
stringMatch(ruName, pattern) or
stringMatch(enName, pattern) then
if Smc.matchItemDescription(ItemStack(craft.output):get_name(), pattern) then
tableInsert(matchedCrafts, craft)
end
end

View File

@@ -2,7 +2,7 @@ local v = vector.new
local assert, ipairs, tostring = assert, ipairs, tostring
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
local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents') --[[@as Events.ImmersiveCraftEvents]]
@@ -83,6 +83,15 @@ end
---@param amount integer
---@return boolean
function ImmersiveCraft:startCraft(pos, player, amount)
if amount <= 0 then
Logger.warningLog('`ImmersiveCraft:startCraft()`: param `amount` <= 0. '..
'Was force-reset to `1`. '..
'Info: value: `%s`, player: `%s`, craft: `%s`',
amount, player:get_player_name(), self.name
)
amount = 1
end
local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
assert(workStation ~= nil)
@@ -124,7 +133,7 @@ function ImmersiveCraft:endCraft(pos, player)
local playerName = meta:get_string('player_name')
assert(playerName ~= '')
local amount = meta:get_float('craft_amount')
assert(amount ~= 0)
assert(amount > 0)
-- Drop the result of crafting.
local dropPos = v(pos) + v(0, 0.9,0)

View File

@@ -2,7 +2,7 @@ local assert = assert
local tableInsert, tableMerge = table.insert, table.merge
local modInfo = Mod.getInfo('smc__core__craft_system')
local modInfo = Mod:getInfo('smc__core__craft_system')
local require = modInfo.require
---@type CraftSystem.BaseCraftHandler

View File

@@ -1,5 +1,5 @@
---@type Creature
local Creature = Mod.getInfo('smc__core__creature').require('Creature')
local Creature = Mod:getInfo('smc__core__creature').require('Creature')
---The entity the player interacts with during immersive crafting.
---@class CraftSystem.ImmersiveCraftNode : Creature

View File

@@ -1,4 +1,4 @@
local require = Mod.getInfo('smc__core__craft_system').require
local require = Mod:getInfo('smc__core__craft_system').require
local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents') --[[@as Events.ImmersiveCraftEvents]]

View File

@@ -3,7 +3,7 @@ local assert = assert
local extend = Class.extend
local coreItemDrop = core.item_drop
local require = Mod.getInfo('smc__core__craft_system').require
local require = Mod:getInfo('smc__core__craft_system').require
local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents') --[[@as Events.ImmersiveCraftEvents]]
@@ -129,7 +129,7 @@ function TappingStage:new(def)
assert(stageData ~= nil)
local amount = meta:get_float('craft_amount')
assert(amount ~= 0)
assert(amount > 0)
---@type CraftSystem.ImmersiveCraftStage.TappingStageData?
local stageData = stageData

View File

@@ -1,6 +1,6 @@
local getInstance, extend = Class.getInstance, Class.extend
local modInfo = Mod.getInfo('smc__core__craft_system')
local modInfo = Mod:getInfo('smc__core__craft_system')
local require = modInfo.require
---@type CraftSystem.BaseCraft

View File

@@ -2,7 +2,7 @@ local extend = Class.extend
local tableInsert, tableSort, tableJoin = table.insert, table.sort, table.join
local modInfo = Mod.getInfo('smc__core__craft_system')
local modInfo = Mod:getInfo('smc__core__craft_system')
local require = modInfo.require
---@type CraftSystem.BaseCraftHandler

View File

@@ -1,6 +1,6 @@
local getInstance, extend = Class.getInstance, Class.extend
local modInfo = Mod.getInfo('smc__core__craft_system')
local modInfo = Mod:getInfo('smc__core__craft_system')
local require = modInfo.require
---@type CraftSystem.BaseCraft

View File

@@ -2,7 +2,7 @@ local HASH_SEPARATOR = ','
local tableInsert, tableCopy, tableSort, tableConcat, tableIsEmpty = table.insert, table.copy, table.sort, table.concat, table.is_empty
local modInfo = Mod.getInfo('smc__core__craft_system')
local modInfo = Mod:getInfo('smc__core__craft_system')
local require = modInfo.require
---@type CraftSystem.BaseCraftHandler

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__creature')
local modInfo = Mod:getInfo('smc__core__creature')
local require = modInfo.require
return require('Creature')

View File

@@ -1 +1,2 @@
name = smc__core__creature
depends = smc__system__system_loader

View File

@@ -48,7 +48,7 @@ function Creature:new(entityDef)
-- Add the short mod name prefix to the entity name.
if s._add_mod_name then
s._name = Mod.getInfo().shortName .. ':' .. s._name
s._name = Mod:getInfo().shortName .. ':' .. s._name
end
local onActivate = c.on_activate or function() end

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__formspec')
local modInfo = Mod:getInfo('smc__core__formspec')
local require = modInfo.require
return require('Formspec')

View File

@@ -745,6 +745,41 @@ function Formspec:imageButton(x, y, w, h, textureName, name, label, pressedTextu
return self
end
---@alias Formspec.ImageButtonRowElement {
--- [1] : string,
--- [2] : string,
--- [3] : string?,
--- [4] : string?,
--- [5] : boolean?,
--- [6] : boolean?,
--- }
---Creates a row of buttons, automatically calculating the coordinates of buttons based on the width.
---
---@see Formspec.imageButton
---@param x number
---@param y number
---@param w number
---@param h number
---@param imageButtonRow Formspec.ImageButtonRowElement[]
---@return Formspec
function Formspec:imageButtonRow(x, y, w, h, imageButtonRow)
---@param element Formspec.ImageButtonRowElement
for i, element in ipairs(imageButtonRow) do
local ex = x + ( ( i - 1 ) * w)
self:imageButton(ex, y, w, h,
element[1],
element[2],
element[3],
element[4],
element[5],
element[6]
)
end
return self
end
---Clickable item image button. When clicked, fields will be sent.
---
---**Element:** `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__immersive_work_station')
local modInfo = Mod:getInfo('smc__core__immersive_work_station')
local require = modInfo.require
return require('ImmersiveWorkStation')

View File

@@ -1,2 +1,2 @@
name = smc__core__immersive_work_station
depends = smc__core__craft_system, smc__core__node, smc__ui__work_station
depends = smc__core__craft_system, smc__core__node, smc__ui__work_station, smc__ui__player_inventory

View File

@@ -178,7 +178,7 @@ end
local handler = CraftSystem:getImmersiveCraftHandler('workbench')
local require = Mod.getInfo('smc__ui__player_inventory').require
local require = Mod:getInfo('smc__ui__player_inventory').require
local baseGetCraftTab = require('PlayerInventoryUI.baseGetCraftTab')
---@param self PlayerInventoryUI

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__item')
local modInfo = Mod:getInfo('smc__core__item')
local require = modInfo.require
return require('Item')

View File

@@ -86,7 +86,7 @@ end
---@param itemDef Item.ItemDefinition
---@return ItemDefinition
local function itemDefToLuantiDef(itemDef)
local modName = Mod.getInfo().shortName
local modName = Mod:getInfo().shortName
local S = core.get_translator(modName)
local s = itemDef.settings
@@ -167,7 +167,7 @@ function Item:new(itemDef)
itemDef = tableMerge(itemDef, self.defaultDef, true) --[[@as Item.ItemDefinition]]
local s = itemDef.settings
local shortModName = Mod.getInfo().shortName
local shortModName = Mod:getInfo().shortName
if s._add_mod_name then
s.name = shortModName .. ':' .. s.name

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__item_factory')
local modInfo = Mod:getInfo('smc__core__item_factory')
local require = modInfo.require
return require('ItemFactory')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__map_gen')
local modInfo = Mod:getInfo('smc__core__map_gen')
local require = modInfo.require
return require('MapGen')

View File

@@ -1,13 +1,15 @@
local assert = assert
local pairs, ipairs = pairs, ipairs
local mathRound, mathRandom, mathClamp = math.round, math.random, math.clamp
local bitToBit, bitBxor, bitRshift, bitBand = bit.tobit, bit.bxor, bit.rshift, bit.band
local mathFloor, mathRound, mathRandom, mathClamp = math.floor, math.round, math.random, math.clamp
local tableInsert, tableSort = table.insert, table.sort
local v = vector.new
local id = core.get_content_id
local AIR_ID = core.CONTENT_AIR
local corePosToString, coreGetUsTime = core.pos_to_string, core.get_us_time
local PcgRandom = PcgRandom
local getInstance = Class.getInstance
@@ -18,7 +20,7 @@ local function mglog(text, ...)
core.log((text):format(...))
end
local require = Mod.getInfo('smc__core__map_gen').require
local require = Mod:getInfo('smc__core__map_gen').require
---Numeric values ​​defining the surface height and climate for the node.
---@alias MapGen.Factors {height:number, temp:number, humidity:number, weight:number}
@@ -209,6 +211,32 @@ function MapGen:getTree(name)
return self.treesByName[name]
end
---Returns a pseudorandom number within
---a specified range based on coordinates.
---
---Use this to generate deterministic random
---numbers within node generation functions.
---@param x integer
---@param y integer
---@param z integer
---@param min integer
---@param max integer
---@return integer
function MapGen:random(x, y, z, min, max)
local n = bitToBit(bitBxor(x, 0xB57B6AE1) * 0x9E3779B9)
n = bitToBit(bitBxor(n, y) * 0x85EBCA6B)
n = bitToBit(bitBxor(n, z) * 0xC2B2AE35)
n = bitBxor(n, bit.rshift(n, 16))
n = bitToBit(n * 0x27D4EB2D)
n = bitBxor(n, bit.rshift(n, 15))
n = bitBand(n, 0x7FFFFFFF)
local range = max - min + 1
return min + mathFloor((n / 2147483648) * range)
end
-- --- API METHODS: REGISTRATION ---
@@ -716,7 +744,7 @@ local function generateNode(mapGenerator, layer, factors, data, data2, index, x,
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'CAVERN_AIR')
-- ... or if the surface height is above the water level...
elseif height > waterLevel then
elseif height >= waterLevel then
--- ... and the height of the block is equal to the height of the surface...
if y == height then
-- ... then turf is generated.
@@ -734,7 +762,7 @@ local function generateNode(mapGenerator, layer, factors, data, data2, index, x,
end
-- ... or if the surface height is below the water level...
elseif height <= waterLevel then
elseif height < waterLevel then
-- ... and if the height of the block falls within the thickness of the soil layer...
if y > height - biome.soilHeight then
-- ... then the river/ocean bottom is generated.
@@ -802,7 +830,7 @@ local function calcNoise2dValue(category, layer, triangle, x, y, z)
-- If the triangle is monochromatic (all peaks have the same color and,
-- accordingly, the same noise), then there is no point in smoothing out the noise.
if triangleColor ~= nil then
return layer:getNoiseByColor(category, triangleColor):get_2d({x = x, y = z})
return layer:getNoiseByColor(category, triangleColor):get_3d({x = x, y = 0, z = z})
end
local peak1 = triangle.p1
@@ -821,15 +849,15 @@ local function calcNoise2dValue(category, layer, triangle, x, y, z)
-- ( peak1 * weight1 + peak2 * weight2 + peak3 * weight3) / totalWeight, when
-- totalWeight = weight1 + weight2 + weight3
local weight = calcWeight(triangle.h1, x, y, z)
noiseValue = noiseValue + noise1:get_2d({x = x, y = z}) * weight
noiseValue = noiseValue + noise1:get_3d({x = x, y = 0, z = z}) * weight
totalWeight = totalWeight + weight
weight = calcWeight(triangle.h2, x, y, z)
noiseValue = noiseValue + noise2:get_2d({x = x, y = z}) * weight
noiseValue = noiseValue + noise2:get_3d({x = x, y = 0, z = z}) * weight
totalWeight = totalWeight + weight
weight = calcWeight(triangle.h3, x, y, z)
noiseValue = noiseValue + noise3:get_2d({x = x, y = z}) * weight
noiseValue = noiseValue + noise3:get_3d({x = x, y = 0, z = z}) * weight
totalWeight = totalWeight + weight
return (noiseValue / totalWeight)
@@ -928,6 +956,7 @@ local function generatorHandler(mapGenerator, layer, data, data2, index, x, y, z
local endGetLayerTime = coreGetUsTime()
local startNoiseCalcTime = endGetLayerTime
-- If the value of the noise is `nil`,
-- then the point does not fall within any of the triangles.
local height, temp, humidity = mapGenerator:getFactors(layer, x, y, z)

View File

@@ -1,6 +1,6 @@
local extend = Class.extend
local require = Mod.getInfo('smc__core__map_gen').require
local require = Mod:getInfo('smc__core__map_gen').require
---@type MapGen.Peak
local Peak = require('MapGen.Peak')

View File

@@ -9,7 +9,7 @@ local corePosToString, coreGetValueNoise = core.pos_to_string, core.get_value_no
local getInstance = Class.getInstance
local require = Mod.getInfo('smc__core__map_gen').require
local require = Mod:getInfo('smc__core__map_gen').require
---@type MapGen.Peak
local Peak = require('MapGen.Peak')

View File

@@ -32,7 +32,7 @@ function Tree:new(name, def)
local intance = getInstance(self, {})
intance.name = name
intance.path = def.path
intance.placerName = Mod.getInfo().shortName..':'..name..'_placer'
intance.placerName = Mod:getInfo().shortName..':'..name..'_placer'
intance:registerPlacer()
@@ -113,7 +113,7 @@ function Tree:place(pos)
local pos1, pos2 = pos - v(16, 0, 16), pos + v(16, 80, 16) --[[@as MapVector]]
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, false, 'place_center_x, place_center_z')
else
coreEmergeArea(pos1, pos2)
end
@@ -122,7 +122,7 @@ end
---@param voxelManip VoxelManip
---@param pos MapVector
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, false, 'place_center_x, place_center_z')
if not result then
voxelManip:set_node_at(pos, {name = self.placerName, force_place = true})

View File

@@ -6,7 +6,7 @@ local v = vector.new
local getInstance = Class.getInstance
local require = Mod.getInfo('smc__core__map_gen').require
local require = Mod:getInfo('smc__core__map_gen').require
---@type MapGen.Edge
local Edge = require('MapGen.Edge')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__node')
local modInfo = Mod:getInfo('smc__core__node')
local require = modInfo.require
return require('Node')

View File

@@ -22,8 +22,8 @@ local function registerSlab(nodeDef)
settings.drawtype = 'nodebox'
settings.paramtype = 'light'
settings.paramtype2 = 'facedir'
settings.groups['segments'] = nil
settings.groups['slabs'] = 1
settings.groups.segments = nil
settings.groups.slabs = 1
if nodeDef.callbacks ~= nil then
nodeDef.callbacks.on_place = core.rotate_and_place
else
@@ -52,8 +52,8 @@ local function registerStair(nodeDef)
settings.drawtype = 'nodebox'
settings.paramtype = 'light'
settings.paramtype2 = 'facedir'
settings.groups['segments'] = nil
settings.groups['slabs'] = 1
settings.groups.segments = nil
settings.groups.stairs = 1
if nodeDef.callbacks ~= nil then
nodeDef.callbacks.on_place = core.rotate_and_place
else
@@ -72,10 +72,12 @@ function Node:new(nodeDef)
local settings = nodeDef.settings
settings._type = 'node'
local instance = Item:new(nodeDef) --[[@as Node]]
-- Registration of segmented blocks.
-- If you specify a specific group with a specific index for a node,
-- the slabs and stairs will be registered automatically.
local segmentsIndex = settings.groups and settings.groups['segments']
local segmentsIndex = settings.groups and settings.groups.segments
if segmentsIndex == 1 then
-- Only slabs
registerSlab(nodeDef)
@@ -88,8 +90,6 @@ function Node:new(nodeDef)
registerStair(nodeDef)
end
local instance = Item:new(nodeDef) --[[@as Node]]
return instance
end

View File

@@ -1,4 +1,4 @@
---@meta
---@class Node.Settings : Item.Settings, NodeDefinition.Settings
---@class Node.Settings : NodeDefinition.Settings, Item.Settings
local Settings = {}

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__plant')
local modInfo = Mod:getInfo('smc__core__plant')
local require = modInfo.require
return require('Plant')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__player')
local modInfo = Mod:getInfo('smc__core__player')
local require = modInfo.require
return require('Player')

View File

@@ -2,7 +2,7 @@
local Player = {}
---@type PlayerInventoryUI
local PlayerInventoryUI = Mod.getInfo('smc__ui__player_inventory').require('PlayerInventoryUI')
local PlayerInventoryUI = Mod:getInfo('smc__ui__player_inventory').require('PlayerInventoryUI')
core.register_on_joinplayer(function(player)
player:set_inventory_formspec(PlayerInventoryUI:getFormSpecString(player:get_player_name()))
@@ -29,7 +29,7 @@ core.register_chatcommand('show_inv',
}
)
local require = Mod.getInfo('smc__core__player').require
local require = Mod:getInfo('smc__core__player').require
require('Player.inventory')

View File

@@ -1,6 +1,2 @@
---@type PlayerInventoryUI
local PlayerInventoryUI = Mod.getInfo('smc__ui__player_inventory').require('PlayerInventoryUI')
-- TODO: перенести обработки в PlayerUI
local PlayerInventoryUI = Mod:getInfo('smc__ui__player_inventory').require('PlayerInventoryUI')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__processing_container_station')
local modInfo = Mod:getInfo('smc__core__processing_container_station')
local require = modInfo.require
return require('ProcessingContainerStation')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__processing_fuel_station')
local modInfo = Mod:getInfo('smc__core__processing_fuel_station')
local require = modInfo.require
return require('ProcessingFuelStation')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__processing_station')
local modInfo = Mod:getInfo('smc__core__processing_station')
local require = modInfo.require
return require('ProcessingStation')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__progression_system')
local modInfo = Mod:getInfo('smc__core__progression_system')
local require = modInfo.require
return require('ProgressionSystem')

View File

@@ -1,6 +1,6 @@
local assert = assert
local require = Mod.getInfo('smc__core__progression_system').require
local require = Mod:getInfo('smc__core__progression_system').require
---@type ProgressionSystem.Age
local Age = require('ProgressionSystem.Age')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__sound')
local modInfo = Mod:getInfo('smc__core__sound')
local require = modInfo.require
return require('Sound')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__tilesheet')
local modInfo = Mod:getInfo('smc__core__tilesheet')
local require = modInfo.require
return require('TileSheet')

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__core__tool')
local modInfo = Mod:getInfo('smc__core__tool')
local require = modInfo.require
return require('Tool')

View File

@@ -3,7 +3,7 @@
--core.set_mapgen_setting('chunksize', '{x=2,y=10,z=2}', true)
local mapGeneneratorRequire = Mod.getInfo('smc__core__map_generator').require
local mapGeneneratorRequire = Mod:getInfo('smc__core__map_generator').require
-- Main env init
local mapGenerator = mapGeneneratorRequire('mapGenerator')
@@ -16,4 +16,4 @@ core.register_mapgen_script(core.get_modpath('smc__core__map_generator')..'/src/
-- For now, the generation does not have its own support
-- for the generation of ores and decorations, so vanilla ones are used.
return mapGenerator
return mapGenerator

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,2 @@
name = smc__core__map_generator
depends = smc__core__map_gen, smc__game__items__rocks, smc__game__items__liquids
depends = smc__core__map_gen, smc__game__items__rocks, smc__game__items__liquids, smc__game__items__soils, smc__game__items__clays, smc__game__items__sands, smc__game__items__plants

View File

@@ -47,4 +47,4 @@ dofile(core.get_modpath('smc__system__helper_lib')..'/src/Lib/color.lua')
---@type MapGen
local mapGenerator = dofile(core.get_modpath('smc__core__map_generator')..'/src/mapGenerator.lua')
mapGenerator:run()
mapGenerator:run()

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,47 @@
local Item, Node, TileSheet = Smc.requireItem(), Smc.requireNode(), Smc.requireTileSheet()
local CraftSystem = Smc.requireCraftSystem()
-- local InventoryCraftHandler = CraftSystem:getPrimitiveCraftHandler('inside_player_inventory')
---@type TileSheet
local clayTileSheet = TileSheet:new('clays_sheet.png', 16, 16)
---@param type string
---@param y integer
local function registerSand(type, y)
Node:new({
settings = {
name = type..'_clay_block',
groups = { clay_block = 1, dig_immediate = 2 },
tiles = { clayTileSheet:t(0, y)}
}
})
Item:new({
settings = {
name = type..'_clay',
inventory_image = clayTileSheet:t(1, y),
groups = { clay = 1 }
}
})
Node:new({
settings = {
name = type..'_clay_bricks',
tiles = { clayTileSheet:t(2, y)},
groups = { clay_bricks = 1, dig_immediate = 2 }
}
})
Item:new({
settings = {
name = type..'_clay_brick',
inventory_image = clayTileSheet:t(3, y),
groups = { clay_brick = 1 }
}
})
end
registerSand('red', 0)
registerSand('white', 1)
registerSand('fireproof', 2)

View File

@@ -0,0 +1,2 @@
name = smc__game__items__clays
depends = smc__core__node, smc__core__tilesheet

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -0,0 +1,67 @@
local Item, Node, TileSheet = Smc.requireItem(), Smc.requireNode(), Smc.requireTileSheet()
local CraftSystem = Smc.requireCraftSystem()
-- local InventoryCraftHandler = CraftSystem:getPrimitiveCraftHandler('inside_player_inventory')
---@type TileSheet
local oreTileSheet = TileSheet:new('ores_sheet.png', 16, 16)
---@class OreDef
---@field rarity Item.Rarity?
---@param name string
---@param y integer
---@param def OreDef?
local function registerOre(name, y, def)
if def == nil then
def = {}
end
Item:new({
settings = {
name = name,
rarity = def.rarity,
inventory_image = oreTileSheet:t(0, y),
groups = { ore = 1 }
}
})
end
-- Ores Items --
-- Slag
registerOre('slag', 0, {})
-- Copper ores
registerOre('chalcopyrite', 1, {})
registerOre('malachite', 2, {})
registerOre('cuprite', 3, {})
registerOre('native_copper', 4, {})
-- Tin ores
registerOre('cassiterite', 5, {})
registerOre('stannite', 6, {})
-- Iron oresLimonite
registerOre('limonite', 7, {})
registerOre('hematite', 8, {})
registerOre('magnetite', 9, {})
registerOre('meteoric_iron', 10, {})
-- Ores blocks --
-- Slag
Node:new({
settings = {
name = 'slag_block',
tiles = { oreTileSheet:t(1, 0) },
groups = { ore = 1, dig_immediate = 2 }
}
})
-- Malachite
Node:new({
settings = {
name = 'malachite_block',
tiles = { oreTileSheet:t(1, 2) },
groups = { ore = 1, dig_immediate = 2 }
}
})

View File

@@ -0,0 +1,2 @@
name = smc__game__items__ores
depends = smc__core__node, smc__core__tilesheet

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -1,16 +1,40 @@
local Plant, TileSheet = Smc.requirePlant(), Smc.requireTileSheet()
Plant:new({
settings = {
name = 'plants',
tiles = { "test_plant.png" },
place_param2 = 3,
},
})
local placeParam2 = {
2,
3,
4,
34,
35,
36
}
local function afterPlaceNode(pos, placer, itemstack, pointed_thing)
local node = core.get_node(pos)
node.param2 = 8 + placeParam2[math.random(#placeParam2)]
core.set_node(pos, node)
end
-- --- Bog plants ---
local BogPlantsTileSheet = TileSheet:new('plants_bog_sheet.png', 16, 16)
for i=1, 3 do
Plant:new({
settings = {
name = 'bog_grass_'..tostring(i),
tiles = { BogPlantsTileSheet:t(i-1, 0) },
place_param2 = 8,
},
callbacks = {
after_place_node = afterPlaceNode,
}
})
end
-- DEBUG
local PlantsTileSheet = TileSheet:new('plants_test_sheet.png', 16, 16)
for i=0, 3 do
Plant:new({
settings = {
@@ -53,6 +77,3 @@ Plant:new({
place_param2 = 3,
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -4,7 +4,7 @@ local CraftSystem = Smc.requireCraftSystem()
local InventoryCraftHandler = CraftSystem:getPrimitiveCraftHandler('inside_player_inventory')
---@type TileSheet
local rocksTileSheet = TileSheet:new("rocks_sheet.png", 16, 16)
local rocksTileSheet = TileSheet:new('rocks_sheet.png', 16, 16)
---@class RockDef
---@field rarity Item.Rarity?
@@ -24,7 +24,7 @@ local function registerSegmentsCrafts(name, craftGroup)
end
---@param name string
---@param y number
---@param y integer
---@param def RockDef?
---@param staff {block:boolean?,bricks:boolean?,pillar:boolean?}
local function registerRock(name, y, def, staff)
@@ -32,7 +32,7 @@ local function registerRock(name, y, def, staff)
def = {}
end
local modPrefix = Mod.getInfo().shortName..':'
local modPrefix = Mod:getInfo().shortName..':'
local craftGroup = 'rocks_'..name..'_staff'
-- Default rock
@@ -150,6 +150,7 @@ local function registerRock(name, y, def, staff)
end
end
--[[
-- Sylite group
registerRock('sylite', 0, {}, {block = true, bricks = true, pillar = true})
registerRock('sylite_gray', 1, {}, {block = true, bricks = true, pillar = true})
@@ -165,11 +166,10 @@ registerRock('falmyte_light', 6, {}, {block = true, bricks = true})
registerRock('falmyte_yellow', 7, {}, {block = true, bricks = true})
registerRock('falmyte_red', 8, {}, {block = true, bricks = true})
registerRock('falmyte_dark', 9, {}, {block = true, bricks = true})
--]]
registerRock('basalt', 0, {}, {block = true, bricks = true})
registerRock('granite_red', 1, {}, {block = true, bricks = true})
registerRock('limestone', 2, {}, {block = true, bricks = true})
registerRock('dolomit', 3, {}, {block = true, bricks = true})
-- TODO:
-- iyellite
-- falmyte
-- hapcoryte
-- burcite
-- felhor
-- malachite

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@@ -0,0 +1,46 @@
local Item, Node, TileSheet = Smc.requireItem(), Smc.requireNode(), Smc.requireTileSheet()
local CraftSystem = Smc.requireCraftSystem()
-- local InventoryCraftHandler = CraftSystem:getPrimitiveCraftHandler('inside_player_inventory')
---@type TileSheet
local sandTileSheet = TileSheet:new('sands_sheet.png', 16, 16)
---@param type string
---@param y integer
local function registerSand(type, y)
local defaultSandNode = Node:getExtended({
settings = {
name = '',
groups = { dig_immediate = 2 }
}
})
defaultSandNode:new({
settings = {
name = type..'_sand',
tiles = { sandTileSheet:t(0, y) },
groups = { sand = 1 }
}
})
defaultSandNode:new({
settings = {
name = type..'_sandstone',
tiles = { sandTileSheet:t(1, y) },
groups = { sandstone = 1 }
}
})
defaultSandNode:new({
settings = {
name = type..'_sandstone_chipped',
tiles = { sandTileSheet:t(2, y) },
groups = { sandstone = 1 }
}
})
end
registerSand('yellow', 0)
registerSand('red', 1)
registerSand('black', 2)

View File

@@ -0,0 +1,2 @@
name = smc__game__items__sands
depends = smc__core__node, smc__core__tilesheet

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -1,7 +1,9 @@
local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
---@type TileSheet
local soilTileSheet = TileSheet:new("soils_sheet.png", 16, 16)
local soilTileSheet = TileSheet:new('soils_sheet.png', 16, 16)
---@type TileSheet
local grassTileSheet = TileSheet:new('soils_grass_sheet.png', 16, 16)
---@class SoilDef
---@field rarity Item.Rarity?
@@ -28,7 +30,10 @@ local function registerSoil(name, x, def, turfs)
defaultSoil:new({
settings = {
name = name,
tiles = {soilTexture}
tiles = { soilTexture },
paramtype2 ='color4dir',
palette = 'soils_grass_palette.png',
drop = 'soils:'..name,
},
})
@@ -56,240 +61,35 @@ local function registerSoil(name, x, def, turfs)
})
if turfs ~= nil then
for turfName, turfX in pairs(turfs) do
for turfName, turfY in pairs(turfs) do
defaultSoil:new({
settings = {
name = turfName,
tiles = {
soilTileSheet:t(turfX,2),
soilTexture,
soilTexture..'^'..soilTileSheet:t(turfX,3)
grassTileSheet:t(0, turfY),
{name = soilTexture, color = 'white'},
},
overlay_tiles = {
'',
'',
grassTileSheet:t(1, turfY),
grassTileSheet:t(2, turfY),
grassTileSheet:t(3, turfY),
grassTileSheet:t(4, turfY),
},
paramtype2 ='color4dir',
palette = 'soils_grass_palette.png',
drop = 'soils:'..turfName,
},
})
end
end
end
--[[
local clayTiles = {
ts:t(0,0)
}
registerSoil('mud', 0, {maxFertility = 20, rarity = 'common'}, {
turf_bog = 0,
})
local sandyTiles = {
ts:t(2,0)
}
local mixedTiles = {
ts:t(4,0)
}
local rockyTiles = {
ts:t(6,0)
}
soilFactory:registerItems({
--- Clay soils
---@type Node.NodeDefinition
{
settings = {
name = "clay_soil_baren",
_title = "Barren Clay Soil",
--description = "",
tiles = clayTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "clay_soil_poor",
_title = "Poor Clay Soil",
--description = "",
tiles = clayTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "clay_soil_moderate",
_title = "Moderate Clay Soil",
--description = "",
tiles = clayTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "clay_soil_fertile",
_title = "Fertile Clay Soil",
--description = "",
tiles = clayTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "clay_soil_rich",
_title = "Rich Clay Soil",
--description = "",
tiles = clayTiles,
},
},
--- Sandy soils
---@type Node.NodeDefinition
{
settings = {
name = "sandy_soil_baren",
_title = "Barren Sandy Soil",
--description = "",
tiles = sandyTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "sandy_soil_poor",
_title = "Poor Sandy Soil",
--description = "",
tiles = sandyTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "sandy_soil_moderate",
_title = "Moderate Sandy Soil",
--description = "",
tiles = sandyTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "sandy_soil_fertile",
_title = "Fertile Sandy Soil",
--description = "",
tiles = sandyTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "sandy_soil_rich",
_title = "Rich Sandy Soil",
--description = "",
tiles = sandyTiles,
},
},
--- Mixed soils
---@type Node.NodeDefinition
{
settings = {
name = "mixed_soil_baren",
_title = "Barren Mixed Soil",
--description = "",
tiles = mixedTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "mixed_soil_poor",
_title = "Poor Mixed Soil",
--description = "",
tiles = mixedTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "mixed_soil_moderate",
_title = "Moderate Mixed Soil",
--description = "",
tiles = mixedTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "mixed_soil_fertile",
_title = "Fertile Mixed Soil",
--description = "",
tiles = mixedTiles,
},
},
---@type Node.NodeDefinition
{
settings = {
name = "mixed_soil_rich",
_title = "Rich Mixed Soil",
--description = "",
tiles = mixedTiles,
},
},
--- Rocky soils
---@type Node.NodeDefinition
{
settings = {
name = "rocky_soil_baren",
_title = "Barren Rocky Soil",
--description = "",
tiles = rockyTiles,
rarity = 'uncommon'
},
},
---@type Node.NodeDefinition
{
settings = {
name = "rocky_soil_poor",
_title = "Poor Rocky Soil",
--description = "",
tiles = rockyTiles,
rarity = 'distinguished'
},
},
---@type Node.NodeDefinition
{
settings = {
name = "rocky_soil_moderate",
_title = "Moderate Rocky Soil",
--description = "",
tiles = rockyTiles,
rarity = 'eminent'
},
},
---@type Node.NodeDefinition
{
settings = {
name = "rocky_soil_fertile",
_title = "Fertile Rocky Soil",
--description = "",
tiles = rockyTiles,
rarity = 'prime'
},
},
---@type Node.NodeDefinition
{
settings = {
name = "rocky_soil_rich",
_title = "Rich Rocky Soil",
--description = "",
tiles = rockyTiles,
},
},
})--]]
---@type TileSheet
local tsT = TileSheet:new("soils_turfs_sheet.png", 16, 16)
registerSoil('humus', 0, {maxFertility = 100, rarity = 'uncommon'}, {turf_meadow=0})
registerSoil('chernozem', 1, {maxFertility = 100, rarity = 'uncommon'}, {
turf_meadow = 0,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -83,6 +83,7 @@ local function registerWood(name, x, def)
def = {}
end
-- Tree log with cut annual rings
defaultLog:new({
settings = {
name = name..'_log',
@@ -96,6 +97,7 @@ local function registerWood(name, x, def)
}
})
-- Stripped Log
defaultLog:new({
settings = {
name = name..'_log_stripped',
@@ -108,25 +110,11 @@ local function registerWood(name, x, def)
}
})
-- Tree trunk completely covered in bark
defaultLog:new({
settings = {
name = name..'_timber',
tiles = {
woodTileSheet:t(x, 8)..'^[transformR90', woodTileSheet:t(x, 8)..'^[transformR90',
woodTileSheet:t(x, 8), woodTileSheet:t(x, 8),
woodTileSheet:t(x, 7), woodTileSheet:t(x, 7)
},
paramtype2 = 'facedir',
_rarity = def.rarity,
groups = {segments = 1}
},
})
defaultLog:new({
settings = {
name = name..'_trunk_6_sides',
name = name..'_trunk',
tiles = {woodTileSheet:t(x, 3)},
inventory_overlay = 'wood_trunk_overlay.png',
drop = 'wood:'..name..'_log',
paramtype2 = 'facedir',
_rarity = def.rarity,
@@ -136,24 +124,13 @@ local function registerWood(name, x, def)
}
})
-- --- Tree branches ---
-- Branch completely covered in bark
defaultLog:new({
settings = {
name = name..'_trunk_4_sides',
tiles = getLogTiles(x, 2),
inventory_overlay = 'wood_trunk_overlay.png',
drop = 'wood:'..name..'_log',
paramtype2 = 'facedir',
_rarity = def.rarity,
},
callbacks = {
on_place = core.rotate_node
}
})
local defaultBranch6Sides = defaultLog:getExtended({
settings = {
drawtype = 'nodebox',
name = '',
name = name..'_log_branch_6_sides',
tiles = {woodTileSheet:t(x, 3)},
paramtype = 'light',
node_box = {
@@ -171,24 +148,11 @@ local function registerWood(name, x, def)
},
})
local node = defaultBranch6Sides:new({
settings = {
name = name..'_log_branch_6_sides',
}
})
defaultBranch6Sides:new({
settings = {
name = name..'_trunk_branch_6_sides',
inventory_overlay = 'wood_trunk_overlay.png',
drop = name..'_log_branch_6_sides',
}
})
local defaultBranch4Sides = defaultLog:getExtended({
-- Branch with cut annual rings
defaultLog:new({
settings = {
drawtype = 'nodebox',
name = '',
name = name..'_log_branch_4_sides',
tiles = getLogTiles(x, 2),
drop = 'wood:'..name..'_log',
paramtype = 'light',
@@ -203,20 +167,43 @@ local function registerWood(name, x, def)
},
})
defaultBranch4Sides:new({
-- Tree leafs
defaultLeafs:new({
settings = {
name = name..'_log_branch_4_sides',
}
})
defaultBranch4Sides:new({
settings = {
name = name..'_trunk_branch_4_sides',
inventory_overlay = 'wood_trunk_overlay.png',
drop = name..'_log_branch_4_sides',
name = name..'_leafs',
tiles = { woodTileSheet:t(x, 1) },
_rarity = def.rarity,
},
})
-- --- Tree lumber ---
-- Timber (block)
defaultLog:new({
settings = {
name = name..'_timber',
tiles = {
woodTileSheet:t(x, 8)..'^[transformR90',
woodTileSheet:t(x, 8)..'^[transformR90',
woodTileSheet:t(x, 8), woodTileSheet:t(x, 8),
woodTileSheet:t(x, 7), woodTileSheet:t(x, 7)
},
paramtype2 = 'facedir',
_rarity = def.rarity,
groups = {segments = 1}
},
})
-- Bar (item)
defaultStick:new({
settings = {
name = name..'_bar',
inventory_image = woodTileSheet:t(x, 11)
}
})
-- Planks (block)
defaultPlanks:new({
settings = {
name = name..'_planks',
@@ -226,21 +213,7 @@ local function registerWood(name, x, def)
},
})
defaultLeafs:new({
settings = {
name = name..'_leafs',
tiles = { woodTileSheet:t(x, 1) },
_rarity = def.rarity,
},
})
defaultStick:new({
settings = {
name = name..'_stick',
inventory_image = woodTileSheet:t(x, 9)
}
})
-- Plank (item)
defaultStick:new({
settings = {
name = name..'_plank',
@@ -248,13 +221,15 @@ local function registerWood(name, x, def)
}
})
defaultStick:new({
-- Stick
defaultStick:new({
settings = {
name = name..'_bar',
inventory_image = woodTileSheet:t(x, 11)
name = name..'_stick',
inventory_image = woodTileSheet:t(x, 9)
}
})
-- --- Crafts ---
InventoryCraftHandler:registerCraft('wood:'..name..'_planks', {
recipe = {
'wood:'..name..'_log'

View File

@@ -1,54 +1,44 @@
local modInfo = Mod.getInfo('smc__core__formspec')
local modInfo = Mod:getInfo('smc__core__formspec')
local require = modInfo.require
---@type AdminListUI
local AdminListUI = Mod.getInfo('smc__ui__admin_list').require('AdminListUI')
---@type PlayerInventoryUI
local PlayerInventoryUI = Mod:getInfo('smc__ui__player_inventory').require('PlayerInventoryUI')
core.register_chatcommand('list', {
privs = {server = true},
privs = {give = true},
func = function(name, param)
local player = core.get_player_by_name(name)
AdminListUI:showForm(name)
PlayerInventoryUI:setContex(name, 'left_tab_name', 'admin_list_tab')
PlayerInventoryUI:showForm(name)
return true, ''
end
})
AdminListUI:registerOnFormFieldActionMatch('%S+::item_button',function(player, fieldName, fieldValue)
---@type ItemStackString?
local stack = string.match(fieldName, '(%S+)::item_button')
core.register_chatcommand('set_param2', {
privs = {server = true},
if stack == nil then
return
func = function(name, param)
local player = core.get_player_by_name(name)
if player == nil then
return
end
local pos = player:get_pos() - vector.new(0, 0.5, 0)
pos = pos:round()
local node = core.get_node(pos)
node.param2 = param
core.set_node(pos, node)
return true, ''
end
local playerName = player:get_player_name()
AdminListUI:setContex(playerName, 'select_item', stack)
AdminListUI:showForm(playerName)
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 = '#FCF0ED',
day_horizon = '#F1D4C3',
day_sky = '#b5e8ff',
day_horizon = '#80bbe2',
},
type = 'regular',
})
@@ -99,11 +89,11 @@ core.register_chatcommand('get_missing_locale', {
local langCodes = params.lang_codes
if shortModName ~= nil and type(shortModName) ~= 'string' then
return false
return false, 'Incorrect mod name'
end
if langCodes ~= nil and type(langCodes) ~= 'table' then
return false
return false, 'Incorrect lang code'
end
local items
@@ -130,3 +120,60 @@ core.register_chatcommand('get_missing_locale', {
return true, ''
end
})
core.register_chatcommand('create_locale', {
privs = { server = true },
description = '<short_mod_name> <lang_code>',
func = function(name, params)
local shortModName, langCode = string.match(params, '(%S+) (%S+)')
if shortModName == nil or shortModName == '' then
return false, 'Incorrect mod name!'
end
if langCode == nil or langCode == '' or not table.contains(LANG_CODES, langCode)then
return false, 'Incorrect lang code!'
end
local items = Smc.getRegisteredItemsListByMod(shortModName)
if items == nil then
return false, 'There are no items registered for this mod (or the entire game)'
end
local filePath = core.get_worldpath()..('/%s.%s.tr'):format(shortModName, langCode)
local file, err = io.open(filePath, 'w')
if not file then
return false, 'Cannot open file: '..err
end
file:write('# textdomain: '..shortModName..'\n\n')
for _, item in ipairs(items) do
local itemSettings = item.itemDef.settings
local name = string.match(itemSettings.name, ('%S+:(%S+)'))
local title = core.strip_colors(core.get_translated_string(langCode, itemSettings._title))
local desc = core.strip_colors(core.get_translated_string(langCode, itemSettings._description))
if title ~= name..'-title' then
title = '[locale already exists]'
else
title = ''
end
if desc ~= name..'-desc' then
desc = '[locale already exists]'
else
desc = ''
end
file:write(('%s-title=%s\n%s-desc=%s\n'):format(name, title, name, desc))
end
file:write('\n')
file:close()
return true, 'File created: '..filePath
end
})

View File

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

View File

@@ -16,7 +16,8 @@ end
---@generic T:table
---@param self T Parent class.
---@param params table Child object parameters.
---@param metatable table? The table that will become the metatable for the object. Note: The `__index` field will be overwritten by a copy of `self`.
---@param metatable table? The table that will become the metatable for the object.
--- Note: The `__index` field will be overwritten by a copy of `self`.
---@return T
function Class.getInstance(self, params, metatable)
if metatable == nil then
@@ -28,4 +29,4 @@ function Class.getInstance(self, params, metatable)
local instance = setmetatable(params, metatable)
return instance
end
end

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__system__events')
local modInfo = Mod:getInfo('smc__system__events')
local require = modInfo.require
return require('Events')

View File

@@ -1,2 +1,2 @@
name = smc__system__events
depends = smc__system__table, smc__system__require, smc__system__class
depends = smc__system__table, smc__system__require, smc__system__class, smc__system__mod

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo('smc__system__helper_lib')
local modInfo = Mod:getInfo('smc__system__helper_lib')
local require = modInfo.require
require('Lib')
require('Lib')

View File

@@ -1,2 +1,2 @@
name = smc__system__helper_lib
depends = smc__system__ensure
depends = smc__system__ensure, smc__system__mod, smc__system__utf8

View File

@@ -1,17 +1,24 @@
---SMC helper lib
---@class Smc
Smc = {}
---@type boolean
Smc.isAsync = false
local modInfo = Mod.getInfo('smc__system__helper_lib')
local require = modInfo.require
local modInfo = Mod:getInfo('smc__system__helper_lib')
local doFile = modInfo.doFile
require('Lib.activeFormspecs')
require('Lib.globalStep')
require('Lib.color')
require('Lib.itemStackInventory')
require('Lib.nodeSuperClasses')
require('Lib.getObjectByGUID')
require('Lib.receiveFields')
require('Lib.registeredItems')
require('Lib.requires')
-- Independent of SMC methods
doFile('Lib.activeFormspecs')
doFile('Lib.globalStep')
doFile('Lib.inventoryHelpers')
doFile('Lib.color')
doFile('Lib.itemStackInventory')
doFile('Lib.nodeSuperClasses')
doFile('Lib.getObjectByGUID')
doFile('Lib.receiveFields')
doFile('Lib.registeredItems')
doFile('Lib.requires')
--- Dependent of SMC methods
doFile('Lib.matchItemDescription')

View File

@@ -54,4 +54,4 @@ function Smc.makeGradient(colorFrom, colorTo, msg)
end
return result
end
end

View File

@@ -0,0 +1,23 @@
local ItemStack = ItemStack
---Adds the specified stack to the player's inventory, provided there is space available.
---
---If there is no space, it drops the stack on the ground.
---
---Returns `true` if the stack was placed in the inventory, and `false` if it was dropped.
---@param player Player
---@param inventory InvRef
---@param item ItemStack|ItemStackString|ItemStackString
---@return boolean
function Smc.putOrDrop(player, inventory, item)
item = ItemStack(item)
if inventory:room_for_item('main', item) then
inventory:add_item('main', item)
return true
else
core.item_drop(item, player, player:get_pos())
return false
end
end

View File

@@ -0,0 +1,70 @@
local ipairs = ipairs
local tableInsert = table.insert
local stringMatch, stringLower = string.match, string_utf8.lower
local coreGetTranslatedString = core.get_translated_string
---Checks whether an item's name and description match a given pattern.
---
---Use it to create unconventional lists based on text searches.
---
---
---For example:
---```lua
------A function for determining a list of crafts that match a text-based search query
---local function getMathedCrafts(crafts, pattern)
--- local pattern = stringLower(pattern)
--- local matchedCrafts = {}
---
--- for _, craft in ipairs(crafts) do
--- if Smc.matchItemDescription(ItemStack(craft.output):get_name(), pattern) then
--- tableInsert(matchedCrafts, craft)
--- end
--- end
---
--- return matchedCrafts
---end
---```
---
---**Note**: to obtain standard lists of items, use: `Smc.getMathedItems()`
---
---@param itemName ItemStackString
---@return boolean
function Smc.matchItemDescription(itemName, pattern)
local ItemStack = ItemStack(itemName)
-- Only items registered via the `Item` wrapper class have an `_title` field.
-- Therefore, `short_description` is used as a fallback title.
local itemTitle = ItemStack:get_definition()._title or ItemStack:get_short_description() or ''
local ruName = stringLower(coreGetTranslatedString('ru', itemTitle))
local enName = stringLower(coreGetTranslatedString('en', itemTitle))
if stringMatch(itemName, pattern) or
stringMatch(ruName, pattern) or
stringMatch(enName, pattern) then
return true
else
return false
end
end
local matchItemDescription = Smc.matchItemDescription
---Returns a list of items whose name or description matches a pattern.
---
---Use this method to retrieve lists of items based on a text search.
---@param items ItemStackString[]
---@param pattern string
---@return ItemStackString[]
function Smc.getMathedItems(items, pattern)
local pattern = stringLower(pattern)
local macthedItems = {}
for _, itemName in ipairs(items) do
if matchItemDescription(itemName, pattern) then
tableInsert(macthedItems, itemName)
end
end
return macthedItems
end

View File

@@ -1,23 +1,30 @@
local tableInsert = table.insert
---@type table<string, Item|Node>
local registeredItems = {}
---@type table<string, table<string, Item|Node>>
local registeredItemsByMod = {}
---@type table<string, (Item|Node)[]>
local registeredItemsListByMod = {}
---@param shortModName string
---@param item Item|Node
function Smc.addRegisteredItem(shortModName, item)
local itemName = item.itemDef.settings.name
local modItems = registeredItemsByMod[shortModName]
if modItems == nil then
registeredItemsByMod[shortModName] = {[itemName]=item}
registeredItems[itemName] = item
return
if registeredItemsByMod[shortModName] == nil then
registeredItemsByMod[shortModName] = {}
end
if registeredItemsListByMod[shortModName] == nil then
registeredItemsListByMod[shortModName] = {}
end
registeredItems[itemName] = item
modItems[itemName] = item
registeredItemsByMod[shortModName] = item
tableInsert(registeredItemsListByMod[shortModName], item)
end
---@param shortModName string
@@ -26,6 +33,12 @@ function Smc.getRegisteredItemsByMod(shortModName)
return table.copy_with_metatables(registeredItemsByMod[shortModName])
end
---@param shortModName string
---@return table<string, Item>?
function Smc.getRegisteredItemsListByMod(shortModName)
return table.copy_with_metatables(registeredItemsListByMod[shortModName])
end
---@param itemName ItemStackString
---@return Item|Node
function Smc.getRegisteredItemByName(itemName)
@@ -49,3 +62,18 @@ function Smc.getItemDefinition(itemName)
return item.itemDef
end
---@param itemName ItemStack|ItemStackString
---@return Item.ItemDefinition|Node.NodeDefinition|nil
function Smc.getItemDefinitionOrNil(itemName)
if type(itemName) ~= 'string' then
itemName = itemName:get_name()
end
local item = Smc.getRegisteredItemByName(itemName)
if item == nil then
return nil
end
return item.itemDef
end

View File

@@ -3,7 +3,7 @@
---@return Item
function Smc.requireItem()
---@type Item
local class = Mod.getInfo('smc__core__item').require('Item')
local class = Mod:getInfo('smc__core__item').require('Item')
return class
end
@@ -11,7 +11,7 @@ end
---@return Node
function Smc.requireNode()
---@type Node
local class = Mod.getInfo('smc__core__node').require('Node')
local class = Mod:getInfo('smc__core__node').require('Node')
return class
end
@@ -19,7 +19,7 @@ end
---@return Tool
function Smc.requireTool()
---@type Tool
local class = Mod.getInfo('smc__core__tool').require('Tool')
local class = Mod:getInfo('smc__core__tool').require('Tool')
return class
end
@@ -27,7 +27,7 @@ end
---@return Plant
function Smc.requirePlant()
---@type Plant
local class = Mod.getInfo('smc__core__plant').require('Plant')
local class = Mod:getInfo('smc__core__plant').require('Plant')
return class
end
@@ -35,7 +35,7 @@ end
---@return ItemFactory
function Smc.requireItemFactory()
---@type ItemFactory
local class = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
local class = Mod:getInfo('smc__core__item_factory').require('ItemFactory')
return class
end
@@ -43,7 +43,7 @@ end
---@return TileSheet
function Smc.requireTileSheet()
---@type TileSheet
local class = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
local class = Mod:getInfo('smc__core__tilesheet').require('TileSheet')
return class
end
@@ -51,7 +51,7 @@ end
---@return BaseUI
function Smc.requireBaseUI()
---@type BaseUI
local class = Mod.getInfo('smc__core__base_ui').require('BaseUI')
local class = Mod:getInfo('smc__core__base_ui').require('BaseUI')
return class
end
@@ -59,7 +59,7 @@ end
---@return Formspec
function Smc.requireFormspec()
---@type Formspec
local class = Mod.getInfo('smc__core__formspec').require('Formspec')
local class = Mod:getInfo('smc__core__formspec').require('Formspec')
return class
end
@@ -67,7 +67,7 @@ end
---@return ProgressionSystem
function Smc.requireProgressionSystem()
---@type ProgressionSystem
local class = Mod.getInfo('smc__core__progression_system').require('ProgressionSystem')
local class = Mod:getInfo('smc__core__progression_system').require('ProgressionSystem')
return class
end
@@ -75,7 +75,7 @@ end
---@return CraftSystem
function Smc.requireCraftSystem()
---@type CraftSystem
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem')
local class = Mod:getInfo('smc__core__craft_system').require('CraftSystem')
return class
end
@@ -83,7 +83,7 @@ end
---@return PlayerInventoryUI
function Smc.requirePlayerInventoryUI()
---@type PlayerInventoryUI
local class = Mod.getInfo('smc__ui__player_inventory').require('PlayerInventoryUI')
local class = Mod:getInfo('smc__ui__player_inventory').require('PlayerInventoryUI')
return class
end
@@ -91,7 +91,7 @@ end
---@return BaseProcessingStation
function Smc.requireBaseProcessingStation()
---@type BaseProcessingStation
local class = Mod.getInfo('smc__core__base_processing_station').require('BaseProcessingStation')
local class = Mod:getInfo('smc__core__base_processing_station').require('BaseProcessingStation')
return class
end
@@ -99,7 +99,7 @@ end
---@return ProcessingContainerStation
function Smc.requireProcessingContainerStation()
---@type ProcessingContainerStation
local class = Mod.getInfo('smc__core__processing_container_station').require('ProcessingContainerStation')
local class = Mod:getInfo('smc__core__processing_container_station').require('ProcessingContainerStation')
return class
end
@@ -107,7 +107,7 @@ end
---@return ProcessingFuelStation
function Smc.requireProcessingFuelStation()
---@type ProcessingFuelStation
local class = Mod.getInfo('smc__core__processing_fuel_station').require('ProcessingFuelStation')
local class = Mod:getInfo('smc__core__processing_fuel_station').require('ProcessingFuelStation')
return class
end
@@ -116,7 +116,7 @@ end
---@return Events
function Smc.requireEvents(eventsType)
---@type Events
local class = Mod.getInfo('smc__system__events').require('Events.'..eventsType)
local class = Mod:getInfo('smc__system__events').require('Events.'..eventsType)
return class
end

View File

@@ -16,4 +16,4 @@ math.lerp = function (a, b, t)
t = math.clamp(t, 0, 1)
return a + (b - a) * t
end
end

View File

@@ -1,12 +1,15 @@
---Luanti mod
---@class Mod
---@field name string Technical name of the mod.
---@field shortName string
---@field path string Path to the mod folder.
---@field Class any A public class that provides a mod.
---@field require fun(FileName:string):table
Mod = {}
---@class Mod.Info
---@field name string
---@field shortName string
---@field path string
---@field require fun(fileName:string):table
---@field loadFile fun(class:table, fileName:string)
---@field doFile fun(fileName:string)
---Returns the mod name without prefixes
---@param name string
---@return string
@@ -18,21 +21,32 @@ end
---Return table with mod name, path and require function.
---@param modname? string Specify a name of mod to get its info
---@return {name: string, shortName: string, path: string, require: fun(FileName : string): table}
function Mod.getInfo(modname)
---@return Mod.Info
function Mod:getInfo(modname)
local name = modname or core.get_current_modname()
local shortName = getShortModName(name)
local path = core.get_modpath(name)
assert(path ~= nil, ('A mod `%s` does not exist.'):format(name))
local require = Require.getModRequire(name, path)
local require = Require:getModRequire(name, path)
local loadFile = Require:getModLoadFile(name, path)
local doFile = Require:getModDoFile(path)
return {name = name, shortName = shortName, path = path, require = require}
local info = {
name = name,
shortName = shortName,
path = path,
require = require,
loadFile = loadFile,
doFile = doFile
}
return info
end
--[[
function Mod:new()
---@type Mod
local instance = setmetatable(Mod.getInfo(), { __index = self })
local instance = setmetatable(Mod:getInfo(), { __index = self })
return instance
end
@@ -65,4 +79,4 @@ function Mod:getModClassExtended(ChildClass)
return childClass
end --]]
return Mod
return Mod

View File

@@ -1 +1,2 @@
name = smc__system__mod
depends = smc__system__require

View File

@@ -2,26 +2,36 @@ Require = {}
local loadedModules = {}
local DS = '/'
--- Creates a scoped require function for a specific module
--- This custom require handles module loading relative to a specific module path,
--- prevents duplicate loading, and caches results appropriately.
--- @param modName string Namespace identifier for the module (prevents global collisions)
--- @param modPath string Absolute base path to the module's directory
--- @return function require Custom require function scoped to the specified module
function Require.getModRequire(modName, modPath)
--- Custom require function for module-specific loading
--- Resolves files relative to modPath/src, converts dot-notation to path separators
--- @param fileName string Module path in dot-notation (e.g. "lib.utils")
--- @return any loadedModule The loaded module's return value or cached result
---A helper function that returns the path to a file.
---@param modPath string
---@param fileName string
---@return string
function Require:getFilePath(modPath, fileName)
return modPath..DS..'src'..DS..fileName:gsub('%.', DS)..'.lua'
end
---Creates a scoped require function for a specific module.
---
---This custom require handles module loading relative to a specific module path,
---prevents duplicate loading, and caches results appropriately.
---@param modName string Namespace identifier for the module (prevents global collisions)
---@param modPath string Absolute base path to the module's directory
---@return function require Custom require function scoped to the specified module
function Require:getModRequire(modName, modPath)
---Custom require function for module-specific loading.
---
---Resolves files relative to modPath/src, converts dot-notation to path separators.
---@param fileName string Module path in dot-notation (e.g. "lib.utils")
---@return table loadedModule The loaded module's return value or cached result
local function require(fileName)
local fullName = modName .. '..' .. fileName
local fullName = modName..'..'..fileName
local module = loadedModules[fullName]
if module ~= nil then
return module
end
local result = dofile(modPath .. DS .. 'src' .. DS .. fileName:gsub('%.', DS) .. '.lua')
local result = dofile(self:getFilePath(modPath, fileName))
if result ~= nil then
loadedModules[fullName] = result
@@ -35,4 +45,57 @@ function Require.getModRequire(modName, modPath)
return require
end
return Require
---Creates a load function bound to a specific module.
---
---This specialized load function ensures that scripts are executed with the specified class passed to them,
---and prevents scripts from being executed more than once by throwing an error.
---@param modName string Namespace identifier for the module (prevents global collisions)
---@param modPath string Absolute base path to the module's directory
---@return function load Custom load function scoped to the specified module
function Require:getModLoadFile(modName, modPath)
---Custom load function for loading modules.
---
---Resolves file paths relative to modPath/src and converts dot notation into path separators.
---@param class table A class within the scope of which a script is to be executed
---@param fileName string Module path in dot-notation (e.g. "lib.utils")
local function loadFile(class, fileName)
local fullName = modName..'..'..fileName
if loadedModules[fullName] ~= nil then
error(('Repeated execute of script `%s` is not allowed.'):format(modPath))
end
local result = loadfile(self:getFilePath(modPath, fileName))
if result == nil then
error()
end
result(class)
loadedModules[fullName] = true
end
return loadFile
end
---Creates dofile function for loading files.
---
---This loading function will execute a standard `dofile` for the specified script.
---@param modPath string Absolute base path to the module's directory
---@return function doFile Custom dofile function scoped to the specified file
function Require:getModDoFile(modPath)
---Custom `dofile` function for loading files.
---
---Resolves file paths relative to modPath/src and converts dot notation into path separators.
---@param fileName string File path in dot-notation (e.g. "lib.utils")
---@return any?
local function doFile(fileName)
local result = dofile(self:getFilePath(modPath, fileName))
return result
end
return doFile
end
return Require

View File

@@ -1,2 +1,2 @@
name = smc__system__string
depends = smc__system__ensure
depends = smc__system__ensure, smc__system__utf8

View File

@@ -1,3 +1,3 @@
name = smc__system__system_loader
description = Include this mod in your `depends` to ensure all necessary Libs are loaded for your mod
depends = smc__system__ensure, smc__system__math, smc__system__mod, smc__system__require, smc__system__table, smc__system__string, smc__system__utf8, smc__system__class, smc__system__helper_lib, smc__system__profiler, smc__system__events
depends = smc__system__ensure, smc__system__math, smc__system__mod, smc__system__require, smc__system__table, smc__system__string, smc__system__utf8, smc__system__class, smc__system__helper_lib, smc__system__profiler, smc__system__events, smc__system__logger

View File

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

View File

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

Some files were not shown because too many files have changed in this diff Show More