11 Commits

28 changed files with 369 additions and 237 deletions

View File

@@ -106,7 +106,7 @@ end
function ImmersiveCraft:startCraft(pos, player, amount) function ImmersiveCraft:startCraft(pos, player, amount)
-- Adding craft to the counter. -- Adding craft to the counter.
-- If crafting has not been added... -- If crafting has not been added...
if not ImmersiveCraftCounter:addCraft(pos, player) then if not ImmersiveCraftCounter:addCraft(pos, player:get_player_name()) then
-- ...then we don't let the player start a new craft. -- ...then we don't let the player start a new craft.
core.chat_send_player(player:get_player_name(), core.chat_send_player(player:get_player_name(),
'The limit of simultaneously active crafts has been reached:'.. 'The limit of simultaneously active crafts has been reached:'..
@@ -142,9 +142,10 @@ function ImmersiveCraft:startCraft(pos, player, amount)
-- Create a temporary data table for crafting. -- Create a temporary data table for crafting.
---@type ImmersiveCraftData ---@type ImmersiveCraftData
local craftData = { local craftData = {
craftName = self.name, playerName = player:get_player_name(), -- The name of the player who started the craft.
stageName = stage.name, craftName = self.name,
amount = amount, stageName = stage.name,
amount = amount,
} }
-- We save it to the workstation metadata. -- We save it to the workstation metadata.
Smc.setCraftDataByPos(pos, craftData) Smc.setCraftDataByPos(pos, craftData)
@@ -157,8 +158,8 @@ end
---Complete the immersive crafting process. ---Complete the immersive crafting process.
---@param pos MapPosition ---@param pos MapPosition
---@param Player Player ---@param player Player
function ImmersiveCraft:endCraft(pos, Player) function ImmersiveCraft:endCraft(pos, player)
-- We get current data on crafting. -- We get current data on crafting.
---@type ImmersiveCraftData? ---@type ImmersiveCraftData?
local craftData = Smc.getCraftDataByPos(pos) local craftData = Smc.getCraftDataByPos(pos)
@@ -170,17 +171,16 @@ function ImmersiveCraft:endCraft(pos, Player)
core.item_drop(ItemStack(self.output), nil, dropPos) core.item_drop(ItemStack(self.output), nil, dropPos)
end end
-- Remove craft from the counter.
ImmersiveCraftCounter:removeCraft(pos, craftData.playerName)
-- Clearing the temporary data table for crafting, freeing up the work station for new crafts. -- Clearing the temporary data table for crafting, freeing up the work station for new crafts.
Smc.setCraftDataByPos(pos) Smc.setCraftDataByPos(pos)
-- Remove craft from the counter.
ImmersiveCraftCounter:removeCraft(pos, Player)
end end
---Stop the crafting process and free up the workbench. ---Stop the crafting process and free up the workbench.
---@param pos MapPosition ---@param pos MapPosition
---@param Player Player function ImmersiveCraft:abortCraft(pos)
function ImmersiveCraft:abortCraft(pos, Player)
-- We get current data on crafting. -- We get current data on crafting.
---@type ImmersiveCraftData? ---@type ImmersiveCraftData?
local craftData = Smc.getCraftDataByPos(pos) local craftData = Smc.getCraftDataByPos(pos)
@@ -188,13 +188,13 @@ function ImmersiveCraft:abortCraft(pos, Player)
-- We get the current stage and start the abort process. -- We get the current stage and start the abort process.
local stage = self.stagesByName[craftData.stageName] local stage = self.stagesByName[craftData.stageName]
stage:abortHandler(pos, Player) stage:abortHandler(pos)
-- Clearing the temporary data table for crafting, freeing up the work station for new crafts. -- Clearing the temporary data table for crafting, freeing up the work station for new crafts.
Smc.setCraftDataByPos(pos) Smc.setCraftDataByPos(pos)
-- Remove craft from the counter. -- Remove craft from the counter.
ImmersiveCraftCounter:removeCraft(pos, Player) ImmersiveCraftCounter:removeCraft(pos, craftData.playerName)
end end
---Returns a human-readable description of the crafting process. ---Returns a human-readable description of the crafting process.

View File

@@ -19,11 +19,10 @@ local ImmersiveCraftCounter = {
---Add craft to the counter. ---Add craft to the counter.
--- ---
---Returns `false` if the counter is already full. ---Returns `false` if the counter is already full.
---@param pos MapPosition ---@param pos MapPosition
---@param Player Player ---@param playerName string
---@return boolean ---@return boolean
function ImmersiveCraftCounter:addCraft(pos, Player) function ImmersiveCraftCounter:addCraft(pos, playerName)
local playerName = Player:get_player_name()
if self.craftsCountForPlayers[playerName] == nil then if self.craftsCountForPlayers[playerName] == nil then
self.craftsCountForPlayers[playerName] = {} self.craftsCountForPlayers[playerName] = {}
end end
@@ -44,10 +43,10 @@ function ImmersiveCraftCounter:addCraft(pos, Player)
end end
---Remove craft from the counter. ---Remove craft from the counter.
---@param pos MapPosition ---@param pos MapPosition
---@param Player Player ---@param playerName string
function ImmersiveCraftCounter:removeCraft(pos, Player) function ImmersiveCraftCounter:removeCraft(pos, playerName)
local playerCrafts = self.craftsCountForPlayers[Player:get_player_name()] local playerCrafts = self.craftsCountForPlayers[playerName]
if playerCrafts == nil then if playerCrafts == nil then
return return
end end

View File

@@ -22,10 +22,14 @@ local tappingNode = ImmersiveCraftNode:new({
_name = 'craft_system:tapping_node', _name = 'craft_system:tapping_node',
_add_mod_name = false, _add_mod_name = false,
---@type ObjectProperties
initial_properties = { initial_properties = {
visual = 'wielditem', visual = 'wielditem',
visual_size = {x=0.4, y=0.4, z=0.4}, visual_size = {x=0.5, y=0.5, z=0.5},
--static_save = false, collisionbox = {
-0.375, -0.375, -0.375,
0.375, 0.375, 0.375
},
}, },
_item_name = '', _item_name = '',

View File

@@ -7,10 +7,10 @@ local getInstance = Class.getInstance
---@field name string ---@field name string
---@field type CraftSystem.ImmersiveCraftStage.Type ---@field type CraftSystem.ImmersiveCraftStage.Type
---@field craftName string ---@field craftName string
---@field startHandler fun(self, pos:Position, Player:Player) ---@field startHandler fun(self, pos:Position, player:Player)
---@field processHandler fun(self, pos:Position, Player:Player) ---@field processHandler fun(self, pos:Position, player:Player)
---@field endHandler fun(self, pos:Position, Player:Player) ---@field endHandler fun(self, pos:Position, player:Player)
---@field abortHandler fun(self, pos:Position, Player:Player) ---@field abortHandler fun(self, pos:Position)
---@field toString fun(self):string ---@field toString fun(self):string
---@field nextStage string? ---@field nextStage string?
---@field returnItems ItemStackString[]? ---@field returnItems ItemStackString[]?

View File

@@ -11,6 +11,7 @@ local ImmersiveCraftStage = require('CraftSystem.ImmersiveCraftStage')
---@class CraftSystem.ImmersiveCraftStage.TappingStage : CraftSystem.ImmersiveCraftStage ---@class CraftSystem.ImmersiveCraftStage.TappingStage : CraftSystem.ImmersiveCraftStage
---@field targetItem string ---@field targetItem string
---@field clicksNeed string ---@field clicksNeed string
---@field toolGroup string?
---@field startHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player) ---@field startHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player)
---@field processHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player) ---@field processHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player)
---@field endHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player) ---@field endHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player)
@@ -23,6 +24,7 @@ local TappingStage = extend(ImmersiveCraftStage, {})
---@class CraftSystem.ImmersiveCraftStage.TappingStageDef : CraftSystem.ImmersiveCraftStageDef ---@class CraftSystem.ImmersiveCraftStage.TappingStageDef : CraftSystem.ImmersiveCraftStageDef
---@field targetItem string ---@field targetItem string
---@field clicksNeed string ---@field clicksNeed string
---@field toolGroup string?
---Data table for transferring various time parameters between calls. ---Data table for transferring various time parameters between calls.
--- ---
@@ -39,11 +41,12 @@ function TappingStage:new(def)
local instance = ImmersiveCraftStage:new(def) 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
-- Registering the crafting stage start handler. -- Registering the crafting stage start handler.
instance.startHandler = function(tappingStage , pos, Player) instance.startHandler = function(tappingStage , pos, player)
-- We determine the coordinate where we will create the crafting node (entity). -- We determine the coordinate where we will create the crafting node (entity).
local entityPos = vector.new(pos) + vector.new(0,0.8,0) local entityPos = vector.new(pos) + vector.new(0,0.875,0)
-- We create a table of initial parameters that we will pass to the entity. -- We create a table of initial parameters that we will pass to the entity.
---@class CraftSystem.ImmersiveCraftStage.TappingNode.InitParams ---@class CraftSystem.ImmersiveCraftStage.TappingNode.InitParams
@@ -75,7 +78,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)
-- Obtaining stage time data from work station metadata. -- Obtaining stage time data from work station metadata.
---@type ImmersiveStageData.TappingStageData? ---@type ImmersiveStageData.TappingStageData?
local stageData = getStageDataByPos(pos) local stageData = getStageDataByPos(pos)
@@ -88,7 +91,7 @@ function TappingStage:new(def)
-- If the number of clicks is greater than required to complete the step... -- If the number of clicks is greater than required to complete the step...
if clickCount >= tappingStage.clicksNeed then if clickCount >= tappingStage.clicksNeed then
-- ...we are completing the stage. -- ...we are completing the stage.
tappingStage:endHandler(pos, Player) tappingStage:endHandler(pos, player)
else else
-- ...else we save the number of clicks in the temporary data table. -- ...else we save the number of clicks in the temporary data table.
stageData.clickCount = clickCount stageData.clickCount = clickCount
@@ -97,7 +100,7 @@ function TappingStage:new(def)
end end
-- Registering the crafting stage end handler. -- Registering the crafting stage end handler.
instance.endHandler = function(tappingStage, pos, Player) instance.endHandler = function(tappingStage, pos, player)
-- Obtaining stage time data from work station metadata. -- Obtaining stage time data from work station metadata.
---@type ImmersiveStageData.TappingStageData? ---@type ImmersiveStageData.TappingStageData?
local stageData = getStageDataByPos(pos) local stageData = getStageDataByPos(pos)
@@ -111,12 +114,12 @@ function TappingStage:new(def)
entity:remove() entity:remove()
-- We trigger an event that the crafting stage has been completed. -- We trigger an event that the crafting stage has been completed.
Events.call('craft_system:next_immersive_stage:'..tappingStage.craftName, tappingStage, pos, Player) Events.call('craft_system:next_immersive_stage:'..tappingStage.craftName, tappingStage, pos, player)
end end
-- Registering the aborting the crafting process handler. -- Registering the aborting the crafting process handler.
---@param tappingStage CraftSystem.ImmersiveCraftStage.TappingStage ---@param tappingStage CraftSystem.ImmersiveCraftStage.TappingStage
instance.abortHandler = function(tappingStage, pos, Player) instance.abortHandler = function(tappingStage, pos)
-- We receive current data on crafting. -- We receive current data on crafting.
---@type ImmersiveCraftData? ---@type ImmersiveCraftData?
local craftData = Smc.getCraftDataByPos(pos) local craftData = Smc.getCraftDataByPos(pos)
@@ -143,7 +146,12 @@ function TappingStage:new(def)
-- Returns a human-readable description of the crafting stage. -- Returns a human-readable description of the crafting stage.
instance.toString = function(tappingStage) instance.toString = function(tappingStage)
local stageDesc = ('Tapping x%s'):format(tappingStage.clicksNeed) local stageDesc
if tappingStage.toolGroup ~= nil then
stageDesc = ('Tapping x%s tool with a group "%s"'):format(tappingStage.clicksNeed, tappingStage.toolGroup)
else
stageDesc = ('Tapping x%s'):format(tappingStage.clicksNeed)
end
return stageDesc return stageDesc
end end
@@ -151,7 +159,17 @@ function TappingStage:new(def)
-- Subscribe to an event that means the player hit the entity. -- Subscribe to an event that means the player hit the entity.
Events.subscribe(('craft_system:punch_tapping_node:%s:%s'):format(instance.craftName, instance.name), Events.subscribe(('craft_system:punch_tapping_node:%s:%s'):format(instance.craftName, instance.name),
---@param craftNode LuaEntity ---@param craftNode LuaEntity
function(eventName, pos, Player, craftNode) ---@param player Player
function(eventName, pos, player, craftNode)
-- We get the item that the player clicked on the crafting node.
local toolDef = player:get_wielded_item():get_definition()
-- If a crafting stage requires a specific tool group and he doesn't have it...
if instance.toolGroup and (not toolDef.groups or not toolDef.groups[instance.toolGroup]) then
-- ...then we don't do anything.
return
end
-- DRAFT START: -- DRAFT START:
-- Creating particles -- Creating particles
for i=0, 10 do for i=0, 10 do
@@ -172,7 +190,7 @@ function TappingStage:new(def)
-- DRAFT END -- DRAFT END
-- Calling the crafting stage process handler. -- Calling the crafting stage process handler.
instance:processHandler(pos, Player) instance:processHandler(pos, player)
end) end)
return instance return instance

View File

@@ -2,10 +2,7 @@ local getInstance, extend = Class.getInstance, Class.extend
local tableCopy, tableMerge, colorize = table.copy, table.merge, core.colorize local tableCopy, tableMerge, colorize = table.copy, table.merge, core.colorize
local modInfo = Mod.getInfo('smc__core__item') local ItemFactory = Smc.requireItemFactory()
local require = modInfo.require
local ItemFactory = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
---Determines whether common rarity will be shown in item descriptions or not. ---Determines whether common rarity will be shown in item descriptions or not.
local SHOW_COMMON_RARITY = true local SHOW_COMMON_RARITY = true
@@ -49,6 +46,7 @@ local Item = {
_description_color = '#C0C0C0', _description_color = '#C0C0C0',
_rarity = 'common', _rarity = 'common',
_add_mod_name = true, _add_mod_name = true,
stack_max = 128,
}, },
callbacks = {} callbacks = {}
} }
@@ -195,7 +193,7 @@ end
---@param defaultDef Item.ItemDefinition ---@param defaultDef Item.ItemDefinition
---@return Item ---@return Item
function Item:getExtended(defaultDef) function Item:getExtended(defaultDef)
defaultDef = defMerge(defaultDef, self.defaultDef) defaultDef = defMerge(defaultDef, self.defaultDef, true)
---@type Item ---@type Item
local ChildClass = extend(self, { local ChildClass = extend(self, {
@@ -212,7 +210,7 @@ function Item:getFactory(defaultDef)
if defaultDef == nil then if defaultDef == nil then
defaultDef = self.defaultDef defaultDef = self.defaultDef
else else
defaultDef = defMerge(self.defaultDef, defaultDef) defaultDef = defMerge(self.defaultDef, defaultDef, true)
end end
---@type ItemFactory ---@type ItemFactory

View File

@@ -1,10 +1,4 @@
local itemRequire = Mod.getInfo('smc__core__item').require local Item, ItemFactory = Smc.requireItem(), Smc.requireItemFactory()
---@type Item
local Item = itemRequire('Item')
---@type ItemFactory
local ItemFactory = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
---@class Node : Item ---@class Node : Item
---@field defaultDef Node.NodeDefinition ---@field defaultDef Node.NodeDefinition

View File

@@ -1,10 +1,4 @@
local nodeRequire = Mod.getInfo('smc__core__node').require local Node = Smc.requireNode()
---@type Node
local Node = nodeRequire('Node')
-- -@type ItemFactory
---local ItemFactory = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
---@class Plant : Node ---@class Plant : Node
local Plant = Node:getExtended({ local Plant = Node:getExtended({
@@ -24,4 +18,4 @@ local Plant = Node:getExtended({
} }
}) })
return Plant return Plant

View File

@@ -6,8 +6,7 @@ local ImmersiveCraftHandler = Mod.getInfo('smc__core__craft_system').require('Cr
---@type WorkStationUI ---@type WorkStationUI
local WorkStationUI = Mod.getInfo('smc__ui__work_station').require('WorkStationUI') local WorkStationUI = Mod.getInfo('smc__ui__work_station').require('WorkStationUI')
---@type Node local Node = Smc.requireNode()
local Node = Mod.getInfo('smc__core__node').require('Node')
-- Default settings that a work station node should have. -- Default settings that a work station node should have.
local WorkStationNode = Node:getExtended({ local WorkStationNode = Node:getExtended({
@@ -79,6 +78,18 @@ function WorkStation:new(name, def)
end end
end end
callbacks.on_punch = function(pos, node, puncher, pointed_thing)
if Smc.workStationIsFree(pos) then
return
end
local craftData = Smc.getCraftDataByPos(pos)
assert(craftData ~= nil, 'Immersive crafting data is empty.')
local craft = ImmersiveCraftHandler:getCraftByName(craftData.craftName)
craft:abortCraft(pos)
end
callbacks.on_dig = function(pos, node, digger) callbacks.on_dig = function(pos, node, digger)
if Smc.workStationIsFree(pos) then if Smc.workStationIsFree(pos) then
return core.node_dig(pos, node, digger) return core.node_dig(pos, node, digger)
@@ -107,6 +118,7 @@ function WorkStation:showSelectionCraftForm(player, crafts, pos)
-- Create a table in the format craft result - craft name. -- Create a table in the format craft result - craft name.
local outputs = {} local outputs = {}
for _, craft in ipairs(crafts) do for _, craft in ipairs(crafts) do
-- TODO: добавить проверку только на известные игроку рецепты
outputs[craft.output] = craft.name outputs[craft.output] = craft.name
end end
@@ -190,6 +202,23 @@ ImmersiveCraftHandler:registerCraft('bricks', {
targetItem = 'rocks:sylite', targetItem = 'rocks:sylite',
type = 'tapping', type = 'tapping',
clicksNeed = 3, clicksNeed = 3,
nextStage = 'tapping_2',
},
---@type CraftSystem.ImmersiveCraftStage.TappingStageDef
{
name = 'tapping_2',
toolGroup = 'crushing',
targetItem = 'rocks:sylite_block',
type = 'tapping',
clicksNeed = 5,
nextStage = 'tapping_3',
},
---@type CraftSystem.ImmersiveCraftStage.TappingStageDef
{
name = 'tapping_3',
targetItem = 'rocks:sylite_bricks',
type = 'tapping',
clicksNeed = 1,
} }
}, },
}) })

View File

@@ -4,43 +4,47 @@ local require = modInfo.require
---@type Formspec ---@type Formspec
local Formspec = require('Formspec') local Formspec = require('Formspec')
local listForm = Formspec:new({ local function getForm()
size = {x=21, y=12}, local listForm = Formspec:new({
}) size = {x=21, y=12},
})
listForm:list('current_player', 'main', 10.5, 6.5, 8, 4) listForm:list('current_player', 'main', 10.5, 6.5, 8, 4)
local listFormItems = Formspec:new() local listFormItems = Formspec:new()
local items = table.get_keys(core.registered_nodes) local items = table.get_keys(core.registered_items)
table.sort(items) table.sort(items)
local w, h = 0, 0 local w, h = 0, 0
---@param name string ---@param name string
for _, name in ipairs(items) do for _, name in ipairs(items) do
listFormItems:itemImageButton(w, h, 1, 1, name, name..'::item_button') listFormItems:itemImageButton(w, h, 1, 1, name, name..'::item_button')
w = w + 1 w = w + 1
if w > 9 then if w >= 9 then
w = 0 w = 0
h = h + 1 h = h + 1
end
end end
--listFormItems:list('current_player', 'main', 0, 0, 1, 32)
listForm:
scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical'):
scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items')
return listForm
end end
--listFormItems:list('current_player', 'main', 0, 0, 1, 32)
listForm:
scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical'):
scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items')
core.register_chatcommand('list', { core.register_chatcommand('list', {
privs = {server = true}, privs = {server = true},
func = function(name, param) func = function(name, param)
local player = core.get_player_by_name(name) local player = core.get_player_by_name(name)
core.show_formspec(name, 'admin_commands:list_form', listForm:toString()) core.show_formspec(name, 'admin_commands:list_form', getForm():toString())
return true, '' return true, ''
end end
@@ -70,4 +74,27 @@ core.register_on_player_receive_fields(function(player, formname, fields)
end end
end end
end end
end) end)
core.register_on_joinplayer(function(player, last_login)
player:set_sky({
sky_color = {
day_sky = '#FAE6E0',
day_horizon = '#E7A985',
},
type = "regular",
})
player:set_lighting({
shadows = { intensity = 0.33 },
volumetric_light = { strength = 0.45 },
exposure = {
luminance_min = -3.5,
luminance_max = -2.5,
exposure_correction = 0.35,
speed_dark_bright = 1500,
speed_bright_dark = 700,
},
saturation = 1.0,
})
end)

View File

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

View File

@@ -1,3 +1,3 @@
name = smc__game__items__items_loader name = smc__game__items__items_loader
description = Include this mod in your `depends` to ensure all items are registered description = Include this mod in your `depends` to ensure all items are registered
depends = smc__game__items__rocks, smc__game__items__wood, smc__game__items__soils, smc__game__items__liquids depends = smc__game__items__rocks, smc__game__items__wood, smc__game__items__soils, smc__game__items__liquids, smc__game__items__plants

View File

@@ -0,0 +1,35 @@
local Item, TileSheet = Smc.requireItem(), Smc.requireTileSheet()
---@type Item.ItemDefinition
local defaultEssenceDef = {
settings = {
name = '',
_rarity = 'uncommon',
stack_max = 32,
}
}
local defaultEssence = Item:getExtended(defaultEssenceDef)
local ts = TileSheet:new('essences_sheet.png', 16, 16)
defaultEssence:new({
settings = {
name = 'essence_experience',
inventory_image = ts:t(0, 0)
}
})
defaultEssence:new({
settings = {
name = 'essence_spell',
inventory_image = ts:t(1, 0)
}
})
defaultEssence:new({
settings = {
name = 'essence_life',
inventory_image = ts:t(2, 0)
}
})

View File

@@ -0,0 +1,10 @@
# textdomain: essences
essence_experience-title=Эссенция опыта
essence_experience-desc=Сгусток желеобразной материи,@nзаключающий в себе ремесленный опыт.
essence_spell-title=Эссенция заклятия
essence_spell-desc=Сгусток желеобразной материи,@nзаключающий в себе мистическую силу.
essence_life-title=Эссенция жизни
essence_life-desc=Сгусток желеобразной материи,@nзаключающий в себе жизненную энергию.

View File

@@ -0,0 +1,2 @@
name = smc__game__items__essences
depends = smc__core__item

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -1,5 +1,4 @@
---@type Node local Node = Smc.requireNode()
local Node = Mod.getInfo('smc__core__node').require('Node')
---@type Node.NodeDefinition ---@type Node.NodeDefinition
local defaultLiquidDef = { local defaultLiquidDef = {

View File

@@ -1,10 +1,4 @@
local modInfo = Mod.getInfo('smc__core__plant') local Plant, TileSheet = Smc.requirePlant(), Smc.requireTileSheet()
---@type TileSheet
local TileSheet = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
---@type Plant
local Plant = modInfo.require('Plant')
Plant:new({ Plant:new({
settings = { settings = {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,8 +1,4 @@
---@type TileSheet local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
local TileSheet = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
---@type Node
local Node = Mod.getInfo('smc__core__node').require('Node')
---@type Node.NodeDefinition ---@type Node.NodeDefinition
local defaultRockDef = { local defaultRockDef = {

View File

@@ -1,8 +1,4 @@
---@type TileSheet local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
local TileSheet = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
---@type Node
local Node = Mod.getInfo('smc__core__node').require('Node')
---@type Node.NodeDefinition ---@type Node.NodeDefinition
local defaultSoilDef = { local defaultSoilDef = {
@@ -12,6 +8,7 @@ local defaultSoilDef = {
tiles = {}, tiles = {},
groups = { groups = {
dig_immediate = 2, dig_immediate = 2,
soil = 1,
soil_fertiliry = 100, -- Soil fertility for agriculture soil_fertiliry = 100, -- Soil fertility for agriculture
} }
}, },
@@ -245,14 +242,10 @@ soilFactory:registerItems({
---@type TileSheet ---@type TileSheet
local tsT = TileSheet:new("soils_turfs_sheet.png", 16, 16) local tsT = TileSheet:new("soils_turfs_sheet.png", 16, 16)
Node:new({ defaultSoil:new({
settings = { settings = {
name = 'turf_swamp', name = 'turf_swamp',
tiles = {tsT:t(0,0), ts:t(6, 0), ts:t(6,0)..'^'..tsT:t(0,1)}, tiles = {tsT:t(0,0), ts:t(6, 0), ts:t(6,0)..'^'..tsT:t(0,1)},
groups = {
dig_immediate = 2,
soil_fertiliry = 100, -- Soil fertility for agriculture
},
_rarity = 'unique' _rarity = 'unique'
} }
}) })

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -1,43 +1,54 @@
---@type Node local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
local Node = Mod.getInfo('smc__core__node').require('Node')
---@type TileSheet
local TileSheet = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
---@type Node.NodeDefinition ---@type Node.NodeDefinition
local defaultRockDef = { local defaultLogDef = {
settings = { settings = {
name = "", name = '',
_description = "A log",
tiles = {}, tiles = {},
groups = { groups = {
dig_immediate = 2, dig_immediate = 2,
wood = 1
}, },
paramtype2 = "facedir", }
},
} }
---@type Node.NodeDefinition ---@type Node.NodeDefinition
local defaultPlanksDef = { local defaultPlanksDef = {
settings = { settings = {
name = "", name = '',
_description = "A planks",
tiles = {}, tiles = {},
groups = { groups = {
dig_immediate = 2, dig_immediate = 2,
}, },
paramtype2 = "facedir", paramtype2 = 'facedir',
}, },
} }
local defaultLog = Node:getExtended(defaultRockDef) ---@type Node.NodeDefinition
local defaultLeafsDef = {
settings = {
drawtype = 'allfaces_optional',
name = '',
tiles = {},
groups = {
dig_immediate = 2,
},
--paramtype = 'light',
paramtype2 = 'facedir',
use_texture_alpha = 'clip',
sunlight_propagates = true,
},
}
local defaultLog = Node:getExtended(defaultLogDef)
local defaultPlanks = Node:getExtended(defaultPlanksDef) local defaultPlanks = Node:getExtended(defaultPlanksDef)
local defaultLeafs = Node:getExtended(defaultLeafsDef)
local logFactory = defaultLog:getFactory() local logFactory = defaultLog:getFactory()
local planksFactory = defaultPlanks:getFactory() local planksFactory = defaultPlanks:getFactory()
---@type TileSheet ---@type TileSheet
local logTileSheet = TileSheet:new("wood_sheet.png", 16, 16) local logTileSheet = TileSheet:new('wood_sheet.png', 16, 16)
local function getLogTiles(x, y) local function getLogTiles(x, y)
return { return {
@@ -47,126 +58,112 @@ local function getLogTiles(x, y)
} }
end end
local t = getLogTiles local t = logTileSheet
logFactory:registerItems({ local function registerWood(name, x)
---@type Node.NodeDefinition defaultLog:new({
{
settings = { settings = {
name = "marentine_log", name = name..'_log',
_title = "Marentine Log", tiles = getLogTiles(x, 1),
--description = "", paramtype2 = 'facedir',
tiles = t(0, 1),
}, },
}, callbacks = {
---@type Node.NodeDefinition on_place = core.rotate_node
{ }
settings = { })
name = "allwhere_log",
_title = "Allwhere Log",
--description = "",
tiles = t(2, 1),
},
},
---@type Node.NodeDefinition
{
settings = {
name = "fis_log",
_title = "Fis Log",
--description = "",
tiles = t(4, 1),
},
},
---@type Node.NodeDefinition
{
settings = {
name = "tammoy_log",
_title = "Tammoy Log",
--description = "",
tiles = t(6, 1),
},
},
---@type Node.NodeDefinition
{
settings = {
name = "dallalia_log",
_title = "Dallalia Log",
--description = "",
tiles = t(8, 1),
},
},
---@type Node.NodeDefinition
{
settings = {
name = "zuph_log",
_title = "Zuph Log",
--description = "",
tiles = t(10, 1),
},
},
})
planksFactory:registerItems({ defaultLog:new({
---@type Node.NodeDefinition
{
settings = { settings = {
name = "marentine_planks", name = name..'_trunk',
_title = "Marentine Planks", tiles = {logTileSheet:t(x, 2)},
--description = "", inventory_overlay = 'wood_trunk_overlay.png',
tiles = { logTileSheet:t(0, 4) }, drop = 'wood:'..name..'_log',
paramtype2 = 'facedir',
}, },
}, callbacks = {
---@type Node.NodeDefinition on_place = core.rotate_node
{ }
})
defaultLog:new({
settings = { settings = {
name = "allwhere_planks", name = name..'_trunk_vertical',
_title = "Allwhere Planks", tiles = getLogTiles(x, 1),
--description = "", inventory_overlay = 'wood_trunk_overlay.png',
tiles = { logTileSheet:t(2, 4) }, drop = 'wood:'..name..'_log',
paramtype2 = 'facedir',
}, },
}, callbacks = {
---@type Node.NodeDefinition on_place = core.rotate_node
{ }
})
defaultLog:new({
settings = { settings = {
name = "fis_planks", drawtype = 'nodebox',
_title = "Fis Planks", name = name..'_trunk_branch',
--description = "", tiles = {logTileSheet:t(x, 2)},
tiles = { logTileSheet:t(4, 4) }, inventory_overlay = 'wood_trunk_overlay.png',
drop = 'wood:'..name..'_log',
paramtype = 'light',
node_box = {
type = 'connected',
fixed = {-.25,-.25,-.25, .25,.25,.25},
connect_top = {-.25,-.25,-.25, .25,.5,.25},
connect_bottom = {-.25,-.5,-.25, .25,.25,.25},
connect_front = {-.25,-.25,-.5, .25,.25,.25},
connect_left = {-.5,-.25,-.25, .25,.25,.25},
connect_back = {-.25,-.25,-.25, .25,.25,.5},
connect_right = {-.25,-.25,-.25, .5,.25,.25},
},
connects_to = {'group:wood', 'group:soil'}
}, },
}, })
---@type Node.NodeDefinition
{ defaultLog:new({
settings = { settings = {
name = "tammoy_planks", drawtype = 'nodebox',
_title = "Tammoy Planks", name = name..'_trunk_branch_vertical',
--description = "", tiles = getLogTiles(x, 1),
tiles = { logTileSheet:t(6, 4) }, inventory_overlay = 'wood_trunk_overlay.png',
drop = 'wood:'..name..'_log',
paramtype = 'light',
node_box = {
type = 'connected',
fixed = {-.25,-.25,-.25, .25,.25,.25},
connect_top = {-.25,-.25,-.25, .25,.5,.25},
connect_bottom = {-.25,-.5,-.25, .25,.25,.25},
},
connects_to = {'group:wood', 'group:soil'}
}, },
}, })
---@type Node.NodeDefinition
{ defaultPlanks:new({
settings = { settings = {
name = "dallalia_planks", name = name..'_planks',
_title = "Dallalia Planks", tiles = { logTileSheet:t(x, 4) },
--description = "",
tiles = { logTileSheet:t(8, 4) },
}, },
}, })
---@type Node.NodeDefinition
{ defaultLeafs:new({
settings = { settings = {
name = "zuph_planks", name = name..'_leafs',
_title = "Zuph Planks", tiles = { logTileSheet:t(x, 0) },
--description = "",
tiles = { logTileSheet:t(10, 4) },
}, },
}, })
}) end
registerWood('marentine', 0)
registerWood('allwhere', 2)
registerWood('fis', 4)
registerWood('tammoy', 6)
registerWood('dallalia', 8)
registerWood('zuph', 10)
-- сундучки -- сундучки
---@type TileSheet ---@type TileSheet
local caseTileSheet = TileSheet:new("cases_sheet.png", 16, 16) local caseTileSheet = TileSheet:new('cases_sheet.png', 16, 16)
local function getCaseTiles(x, y) local function getCaseTiles(x, y)
return { return {
@@ -182,22 +179,22 @@ planksFactory:registerItems({
---@type Node.NodeDefinition ---@type Node.NodeDefinition
{ {
settings = { settings = {
name = "case_closed", name = 'case_closed',
_title = "Case", _title = 'Case',
--description = "", --description = '',
tiles = t(0,0) tiles = t(0,0)
}, },
}, },
---@type Node.NodeDefinition ---@type Node.NodeDefinition
{ {
settings = { settings = {
name = "case_open", name = 'case_open',
_title = "Case", _title = 'Case',
--description = "", --description = '',
tiles = t(1,0); tiles = t(1,0);
drawtype = 'nodebox'; drawtype = 'nodebox';
node_box = { node_box = {
type = "fixed", type = 'fixed',
fixed = { fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5 - 1/16*2, 0.5}, {-0.5, -0.5, -0.5, 0.5, 0.5 - 1/16*2, 0.5},
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -7,4 +7,5 @@ require('Lib.globalStep')
require('Lib.color') require('Lib.color')
require('Lib.immersiveCraftData') require('Lib.immersiveCraftData')
require('Lib.getObjectByGUID') require('Lib.getObjectByGUID')
require('Lib.receiveFields') require('Lib.receiveFields')
require('Lib.requires')

View File

@@ -3,10 +3,11 @@ local EMPTY_FLAG = 'EMPTY_FLAG'
---@class ImmersiveStageData ---@class ImmersiveStageData
---@class ImmersiveCraftData ---@class ImmersiveCraftData
---@field craftName string ---@field playerName string The name of the player who started the craft.
---@field stageName string ---@field craftName string
---@field amount integer ---@field stageName string
---@field stageData ImmersiveStageData? ---@field amount integer
---@field stageData ImmersiveStageData?
---Returns craft data for immersive crafting, which is stored in the desktop metadata. ---Returns craft data for immersive crafting, which is stored in the desktop metadata.
---@param meta NodeMetaRef ---@param meta NodeMetaRef

View File

@@ -0,0 +1,41 @@
-- Global methods for require classes.
---@return Item
function Smc.requireItem()
---@type Item
local class = Mod.getInfo('smc__core__item').require('Item')
return class
end
---@return Node
function Smc.requireNode()
---@type Node
local class = Mod.getInfo('smc__core__node').require('Node')
return class
end
---@return Plant
function Smc.requirePlant()
---@type Plant
local class = Mod.getInfo('smc__core__plant').require('Plant')
return class
end
---@return ItemFactory
function Smc.requireItemFactory()
---@type ItemFactory
local class = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
return class
end
---@return TileSheet
function Smc.requireTileSheet()
---@type TileSheet
local class = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
return class
end