15 Commits

41 changed files with 622 additions and 391 deletions

View File

@@ -106,7 +106,7 @@ end
function ImmersiveCraft:startCraft(pos, player, amount)
-- Adding craft to the counter.
-- 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.
core.chat_send_player(player:get_player_name(),
'The limit of simultaneously active crafts has been reached:'..
@@ -142,6 +142,7 @@ function ImmersiveCraft:startCraft(pos, player, amount)
-- Create a temporary data table for crafting.
---@type ImmersiveCraftData
local craftData = {
playerName = player:get_player_name(), -- The name of the player who started the craft.
craftName = self.name,
stageName = stage.name,
amount = amount,
@@ -157,8 +158,8 @@ end
---Complete the immersive crafting process.
---@param pos MapPosition
---@param Player Player
function ImmersiveCraft:endCraft(pos, Player)
---@param player Player
function ImmersiveCraft:endCraft(pos, player)
-- We get current data on crafting.
---@type ImmersiveCraftData?
local craftData = Smc.getCraftDataByPos(pos)
@@ -170,17 +171,16 @@ function ImmersiveCraft:endCraft(pos, Player)
core.item_drop(ItemStack(self.output), nil, dropPos)
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.
Smc.setCraftDataByPos(pos)
-- Remove craft from the counter.
ImmersiveCraftCounter:removeCraft(pos, Player)
end
---Stop the crafting process and free up the workbench.
---@param pos MapPosition
---@param Player Player
function ImmersiveCraft:abortCraft(pos, Player)
function ImmersiveCraft:abortCraft(pos)
-- We get current data on crafting.
---@type ImmersiveCraftData?
local craftData = Smc.getCraftDataByPos(pos)
@@ -188,13 +188,13 @@ function ImmersiveCraft:abortCraft(pos, Player)
-- We get the current stage and start the abort process.
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.
Smc.setCraftDataByPos(pos)
-- Remove craft from the counter.
ImmersiveCraftCounter:removeCraft(pos, Player)
ImmersiveCraftCounter:removeCraft(pos, craftData.playerName)
end
---Returns a human-readable description of the crafting process.

View File

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

View File

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

View File

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

View File

@@ -11,6 +11,7 @@ local ImmersiveCraftStage = require('CraftSystem.ImmersiveCraftStage')
---@class CraftSystem.ImmersiveCraftStage.TappingStage : CraftSystem.ImmersiveCraftStage
---@field targetItem string
---@field clicksNeed string
---@field toolGroup string?
---@field startHandler 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)
@@ -23,6 +24,7 @@ local TappingStage = extend(ImmersiveCraftStage, {})
---@class CraftSystem.ImmersiveCraftStage.TappingStageDef : CraftSystem.ImmersiveCraftStageDef
---@field targetItem string
---@field clicksNeed string
---@field toolGroup string?
---Data table for transferring various time parameters between calls.
---
@@ -39,11 +41,12 @@ function TappingStage:new(def)
local instance = ImmersiveCraftStage:new(def)
instance.targetItem = def.targetItem
instance.clicksNeed = def.clicksNeed
instance.toolGroup = def.toolGroup
-- 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).
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.
---@class CraftSystem.ImmersiveCraftStage.TappingNode.InitParams
@@ -75,7 +78,7 @@ function TappingStage:new(def)
-- Registering the crafting stage process handler.
-- 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.
---@type ImmersiveStageData.TappingStageData?
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 clickCount >= tappingStage.clicksNeed then
-- ...we are completing the stage.
tappingStage:endHandler(pos, Player)
tappingStage:endHandler(pos, player)
else
-- ...else we save the number of clicks in the temporary data table.
stageData.clickCount = clickCount
@@ -97,7 +100,7 @@ function TappingStage:new(def)
end
-- 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.
---@type ImmersiveStageData.TappingStageData?
local stageData = getStageDataByPos(pos)
@@ -111,12 +114,12 @@ function TappingStage:new(def)
entity:remove()
-- 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
-- Registering the aborting the crafting process handler.
---@param tappingStage CraftSystem.ImmersiveCraftStage.TappingStage
instance.abortHandler = function(tappingStage, pos, Player)
instance.abortHandler = function(tappingStage, pos)
-- We receive current data on crafting.
---@type ImmersiveCraftData?
local craftData = Smc.getCraftDataByPos(pos)
@@ -143,7 +146,12 @@ function TappingStage:new(def)
-- Returns a human-readable description of the crafting stage.
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
end
@@ -151,7 +159,17 @@ function TappingStage:new(def)
-- 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),
---@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:
-- Creating particles
for i=0, 10 do
@@ -172,7 +190,7 @@ function TappingStage:new(def)
-- DRAFT END
-- Calling the crafting stage process handler.
instance:processHandler(pos, Player)
instance:processHandler(pos, player)
end)
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 modInfo = Mod.getInfo('smc__core__item')
local require = modInfo.require
local ItemFactory = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
local ItemFactory = Smc.requireItemFactory()
---Determines whether common rarity will be shown in item descriptions or not.
local SHOW_COMMON_RARITY = true
@@ -37,7 +34,7 @@ local RARITY_INDEX = {
---@class Item
---@field itemDef Item.ItemDefinition
---@field luantiDef ItemDefinition
---@field getVisual fun(): string
---@field getType fun():string
---@field defaultDef Item.ItemDefinition
local Item = {
defaultDef = {
@@ -49,6 +46,7 @@ local Item = {
_description_color = '#C0C0C0',
_rarity = 'common',
_add_mod_name = true,
stack_max = 128,
},
callbacks = {}
}
@@ -123,7 +121,7 @@ local function itemDefToLuantiDef(itemDef)
end
---@param luantiDef NodeDefinition
local function register3dItem(luantiDef)
local function registerNode(luantiDef)
local name = luantiDef.name
luantiDef.name = nil
@@ -131,13 +129,21 @@ local function register3dItem(luantiDef)
end
---@param luantiDef ItemDefinition
local function registerFlatItem(luantiDef)
local function registerCraftitem(luantiDef)
local name = luantiDef.name
luantiDef.name = nil
core.register_craftitem(':'..name, luantiDef)
end
---@param luantiDef ItemDefinition
local function registerTool(luantiDef)
local name = luantiDef.name
luantiDef.name = nil
core.register_tool(':'..name, luantiDef)
end
---The alias `table.merge` for EmmyLua
---@type fun(...):(Item.ItemDefinition)
local defMerge = function(...)
@@ -164,23 +170,26 @@ function Item:new(itemDef)
local instance = getInstance(self, {})
local luantiDef = itemDefToLuantiDef(itemDef)
local visual = itemDef.settings._visual
local type = itemDef.settings._type
if visual == nil then
visual = 'item_2d'
if type == nil then
type = 'craftitem'
end
itemDef.settings._visual = nil
itemDef.settings._type = nil
if visual == 'item_3d' then
register3dItem(luantiDef)
if type == 'node' then
registerNode(luantiDef)
elseif type == 'craftitem' then
registerCraftitem(luantiDef)
elseif type == 'tool' then
registerTool(luantiDef)
else
visual = 'item_2d'
registerFlatItem(luantiDef)
error(('Unknown item type: `%s`.'):format(type))
end
function instance:getVisual()
return visual
function instance:getType()
return type
end
instance.itemDef = itemDef
@@ -195,7 +204,7 @@ end
---@param defaultDef Item.ItemDefinition
---@return Item
function Item:getExtended(defaultDef)
defaultDef = defMerge(defaultDef, self.defaultDef)
defaultDef = defMerge(defaultDef, self.defaultDef, true)
---@type Item
local ChildClass = extend(self, {
@@ -212,7 +221,7 @@ function Item:getFactory(defaultDef)
if defaultDef == nil then
defaultDef = self.defaultDef
else
defaultDef = defMerge(self.defaultDef, defaultDef)
defaultDef = defMerge(self.defaultDef, defaultDef, true)
end
---@type ItemFactory

View File

@@ -33,8 +33,8 @@ Settings._title_color = nil
Settings._description_color = nil
---Visual node type.
---@type Item.Visual?
Settings._visual = nil
---@type Item.Type?
Settings._type = nil
---Formal (lore) rarity of an item. Default `common`.
---@type Item.Rarity?

View File

@@ -0,0 +1 @@
---@alias Item.Type 'craftitem'|'node'|'tool'

View File

@@ -1 +0,0 @@
---@alias Item.Visual 'item_2d'|'item_3d'

View File

@@ -1,10 +1,4 @@
local itemRequire = Mod.getInfo('smc__core__item').require
---@type Item
local Item = itemRequire('Item')
---@type ItemFactory
local ItemFactory = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
local Item, ItemFactory = Smc.requireItem(), Smc.requireItemFactory()
---@class Node : Item
---@field defaultDef Node.NodeDefinition
@@ -22,7 +16,7 @@ function Node:new(nodeDef)
---Adding default parameters
nodeDef = defMerge(nodeDef, self.defaultDef, true)
nodeDef.settings._visual = 'item_3d'
nodeDef.settings._type = 'node'
---@type Node
local instance = Item:new(nodeDef)

View File

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

4
mods/CORE/Tool/init.lua Normal file
View File

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

2
mods/CORE/Tool/mod.conf Normal file
View File

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

View File

@@ -0,0 +1,70 @@
local Item, ItemFactory = Smc.requireItem(), Smc.requireItemFactory()
---@class Tool : Item
---@field defaultDef Item.ItemDefinition
local Tool = Class.extend(Item, {})
---The alias `table.merge` for EmmyLua
---@type fun(...):(Item.ItemDefinition)
local defMerge = function(...)
return table.merge(...)
end
---@param ToolDef Item.ItemDefinition
---@return Tool
function Tool:new(ToolDef)
---Adding default parameters
ToolDef = defMerge(ToolDef, self.defaultDef, true)
ToolDef.settings._type = 'tool'
---@type Tool
local instance = Item:new(ToolDef)
return instance
end
---Allows you to create a child class of an tool by specifying
---default parameters that will be added to the tool's parameters
---when an instance is received.
---@param defaultDef Item.ItemDefinition
---@return Tool
function Tool:getExtended(defaultDef)
defaultDef = defMerge(defaultDef, self.defaultDef)
---@type Tool
local ChildClass = Class.extend(self, {
defaultDef = defaultDef,
})
return ChildClass
end
---Returns an instance of the `ItemFactory` class that can be used to mass-register identical items.
---@param defaultDef? Item.ItemDefinition
---@return ItemFactory
function Tool:getFactory(defaultDef)
if defaultDef == nil then
defaultDef = self.defaultDef
else
defaultDef = defMerge(self.defaultDef, defaultDef)
end
---@type ItemFactory
local instance = ItemFactory:new(self, defaultDef)
return instance
end
--[[
Tool:new({
settings = {
name = 'tool',
inventory_image = 'anoba.png',
tool_capabilities = {
groupcaps={
crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
},
}
}
})--]]
return Tool

View File

@@ -6,8 +6,7 @@ local ImmersiveCraftHandler = Mod.getInfo('smc__core__craft_system').require('Cr
---@type WorkStationUI
local WorkStationUI = Mod.getInfo('smc__ui__work_station').require('WorkStationUI')
---@type Node
local Node = Mod.getInfo('smc__core__node').require('Node')
local Node = Smc.requireNode()
-- Default settings that a work station node should have.
local WorkStationNode = Node:getExtended({
@@ -79,6 +78,18 @@ function WorkStation:new(name, def)
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)
if Smc.workStationIsFree(pos) then
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.
local outputs = {}
for _, craft in ipairs(crafts) do
-- TODO: добавить проверку только на известные игроку рецепты
outputs[craft.output] = craft.name
end
@@ -190,6 +202,23 @@ ImmersiveCraftHandler:registerCraft('bricks', {
targetItem = 'rocks:sylite',
type = 'tapping',
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

@@ -1,73 +0,0 @@
local modInfo = Mod.getInfo('smc__core__formspec')
local require = modInfo.require
---@type Formspec
local Formspec = require('Formspec')
local listForm = Formspec:new({
size = {x=21, y=12},
})
listForm:list('current_player', 'main', 10.5, 6.5, 8, 4)
local listFormItems = Formspec:new()
local items = table.get_keys(core.registered_nodes)
table.sort(items)
local w, h = 0, 0
---@param name string
for _, name in ipairs(items) do
listFormItems:itemImageButton(w, h, 1, 1, name, name..'::item_button')
w = w + 1
if w > 9 then
w = 0
h = h + 1
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', {
privs = {server = true},
func = function(name, param)
local player = core.get_player_by_name(name)
core.show_formspec(name, 'admin_commands:list_form', listForm:toString())
return true, ''
end
})
core.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= 'admin_commands:list_form' then
return
end
for key, value in pairs(fields) do
if string.ends_with(key, '::item_button') then
---@type ItemStackString?
local stack = string.match(key, '(%S+)::item_button')
if stack == nil then
return
end
core.log(tostring(stack))
---@type InvRef
local inv = player:get_inventory()
if inv:room_for_item("main", stack) then
inv:add_item("main", stack)
end
end
end
end)

View File

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

View File

@@ -1,3 +1,3 @@
name = smc__game__items__items_loader
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 = Mod.getInfo('smc__core__node').require('Node')
local Node = Smc.requireNode()
---@type Node.NodeDefinition
local defaultLiquidDef = {

View File

@@ -1,10 +1,4 @@
local modInfo = Mod.getInfo('smc__core__plant')
---@type TileSheet
local TileSheet = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
---@type Plant
local Plant = modInfo.require('Plant')
local Plant, TileSheet = Smc.requirePlant(), Smc.requireTileSheet()
Plant:new({
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 TileSheet = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
---@type Node
local Node = Mod.getInfo('smc__core__node').require('Node')
local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
---@type Node.NodeDefinition
local defaultRockDef = {
@@ -59,6 +55,8 @@ local function registerPilarStaff(rock, y)
})
end
registerPilarStaff('sylite', 0)
registerPilarStaff('sylite_gray', 1)
registerPilarStaff('sylite_black', 2)
registerRocksTypes('', 0)
@@ -66,81 +64,3 @@ registerRocksTypes('_chipped', 1)
registerRocksTypes('_block', 3)
registerRocksTypes('_bricks', 4)
registerRocksTypes('_bricks_2', 5)
--[[
rockFactory:registerItems({
---@type Node.NodeDefinition
{
settings = {
name = "sylite",
title = "Sylite",
--description = "",
tiles = {"rocks_sheet.png^[sheet:7x15:0,0"},
},
},
---@type Node.NodeDefinition
{
settings = {
name = "tauitite",
title = "Tauitite",
--description = "",
tiles = {"rocks_sheet.png^[sheet:7x15:0,2"},
},
},
---@type Node.NodeDefinition
{
settings = {
name = "iyellite",
title = "Iyellite",
--description = "",
tiles = {"rocks_sheet.png^[sheet:7x15:0,4"},
},
},
---@type Node.NodeDefinition
{
settings = {
name = "falmyte",
title = "Falmyte",
--description = "",
tiles = {"rocks_sheet.png^[sheet:7x15:0,6"},
},
},
---@type Node.NodeDefinition
{
settings = {
name = "hapcoryte",
title = "Hapcoryte",
--description = "",
tiles = {"rocks_sheet.png^[sheet:7x15:0,8"},
},
},
---@type Node.NodeDefinition
{
settings = {
name = "burcite",
title = "Burcite",
--description = "",
tiles = {"rocks_sheet.png^[sheet:7x15:0,10"},
},
},
---@type Node.NodeDefinition
{
settings = {
name = "felhor",
title = "Felhor",
--description = "",
tiles = {"rocks_sheet.png^[sheet:7x15:0,12"},
},
},
---@type Node.NodeDefinition
{
settings = {
name = "malachite",
title = "Malachite",
--description = "",
tiles = {"rocks_sheet.png^[sheet:7x15:0,14"},
},
},
})
--]]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 151 KiB

View File

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

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 = Mod.getInfo('smc__core__node').require('Node')
---@type TileSheet
local TileSheet = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
---@type Node.NodeDefinition
local defaultRockDef = {
local defaultLogDef = {
settings = {
name = "",
_description = "A log",
name = '',
tiles = {},
groups = {
dig_immediate = 2,
wood = 1
},
paramtype2 = "facedir",
},
}
}
---@type Node.NodeDefinition
local defaultPlanksDef = {
settings = {
name = "",
_description = "A planks",
name = '',
tiles = {},
groups = {
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 defaultLeafs = Node:getExtended(defaultLeafsDef)
local logFactory = defaultLog:getFactory()
local planksFactory = defaultPlanks:getFactory()
---@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)
return {
@@ -47,126 +58,136 @@ local function getLogTiles(x, y)
}
end
local t = getLogTiles
local t = logTileSheet
logFactory:registerItems({
---@type Node.NodeDefinition
{
local function registerWood(name, x)
defaultLog:new({
settings = {
name = "marentine_log",
_title = "Marentine Log",
--description = "",
tiles = t(0, 1),
name = name..'_log',
tiles = getLogTiles(x, 2),
paramtype2 = 'facedir',
},
},
---@type Node.NodeDefinition
{
callbacks = {
on_place = core.rotate_node
}
})
defaultLog:new({
settings = {
name = "allwhere_log",
_title = "Allwhere Log",
--description = "",
tiles = t(2, 1),
name = name..'_log_stripped',
tiles = getLogTiles(x, 4),
paramtype2 = 'facedir',
},
},
---@type Node.NodeDefinition
{
callbacks = {
on_place = core.rotate_node
}
})
defaultLog:new({
settings = {
name = "fis_log",
_title = "Fis Log",
--description = "",
tiles = t(4, 1),
name = name..'_timber',
tiles = {logTileSheet:t(x, 8), logTileSheet:t(x, 8),
logTileSheet:t(x, 7), logTileSheet:t(x, 7),
logTileSheet:t(x, 8), logTileSheet:t(x, 8),},
paramtype2 = 'facedir',
},
},
---@type Node.NodeDefinition
{
callbacks = {
on_place = core.rotate_node
}
})
defaultLog:new({
settings = {
name = "tammoy_log",
_title = "Tammoy Log",
--description = "",
tiles = t(6, 1),
name = name..'_trunk',
tiles = {logTileSheet:t(x, 3)},
inventory_overlay = 'wood_trunk_overlay.png',
drop = 'wood:'..name..'_log',
paramtype2 = 'facedir',
},
},
---@type Node.NodeDefinition
{
callbacks = {
on_place = core.rotate_node
}
})
defaultLog:new({
settings = {
name = "dallalia_log",
_title = "Dallalia Log",
--description = "",
tiles = t(8, 1),
name = name..'_trunk_vertical',
tiles = getLogTiles(x, 2),
inventory_overlay = 'wood_trunk_overlay.png',
drop = 'wood:'..name..'_log',
paramtype2 = 'facedir',
},
},
---@type Node.NodeDefinition
{
callbacks = {
on_place = core.rotate_node
}
})
defaultLog:new({
settings = {
name = "zuph_log",
_title = "Zuph Log",
--description = "",
tiles = t(10, 1),
drawtype = 'nodebox',
name = name..'_trunk_branch',
tiles = {logTileSheet:t(x, 3)},
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'}
},
})
planksFactory:registerItems({
---@type Node.NodeDefinition
{
defaultLog:new({
settings = {
name = "marentine_planks",
_title = "Marentine Planks",
--description = "",
tiles = { logTileSheet:t(0, 4) },
},
},
---@type Node.NodeDefinition
{
settings = {
name = "allwhere_planks",
_title = "Allwhere Planks",
--description = "",
tiles = { logTileSheet:t(2, 4) },
},
},
---@type Node.NodeDefinition
{
settings = {
name = "fis_planks",
_title = "Fis Planks",
--description = "",
tiles = { logTileSheet:t(4, 4) },
},
},
---@type Node.NodeDefinition
{
settings = {
name = "tammoy_planks",
_title = "Tammoy Planks",
--description = "",
tiles = { logTileSheet:t(6, 4) },
},
},
---@type Node.NodeDefinition
{
settings = {
name = "dallalia_planks",
_title = "Dallalia Planks",
--description = "",
tiles = { logTileSheet:t(8, 4) },
},
},
---@type Node.NodeDefinition
{
settings = {
name = "zuph_planks",
_title = "Zuph Planks",
--description = "",
tiles = { logTileSheet:t(10, 4) },
drawtype = 'nodebox',
name = name..'_trunk_branch_vertical',
tiles = getLogTiles(x, 2),
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'}
},
})
defaultPlanks:new({
settings = {
name = name..'_planks',
tiles = { logTileSheet:t(x, 6) },
},
})
defaultLeafs:new({
settings = {
name = name..'_leafs',
tiles = { logTileSheet:t(x, 1) },
},
})
end
registerWood('marentine', 0)
registerWood('allwhere', 1)
registerWood('fis', 2)
registerWood('tammoy', 3)
registerWood('dallalia', 5)
registerWood('zuph', 6)
-- сундучки
---@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)
return {
@@ -182,22 +203,22 @@ planksFactory:registerItems({
---@type Node.NodeDefinition
{
settings = {
name = "case_closed",
_title = "Case",
--description = "",
name = 'case_closed',
_title = 'Case',
--description = '',
tiles = t(0,0)
},
},
---@type Node.NodeDefinition
{
settings = {
name = "case_open",
_title = "Case",
--description = "",
name = 'case_open',
_title = 'Case',
--description = '',
tiles = t(1,0);
drawtype = 'nodebox';
node_box = {
type = "fixed",
type = 'fixed',
fixed = {
{-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

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

View File

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

View File

@@ -8,3 +8,4 @@ require('Lib.color')
require('Lib.immersiveCraftData')
require('Lib.getObjectByGUID')
require('Lib.receiveFields')
require('Lib.requires')

View File

@@ -3,6 +3,7 @@ local EMPTY_FLAG = 'EMPTY_FLAG'
---@class ImmersiveStageData
---@class ImmersiveCraftData
---@field playerName string The name of the player who started the craft.
---@field craftName string
---@field stageName string
---@field amount integer

View File

@@ -0,0 +1,66 @@
-- 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 Tool
function Smc.requireTool()
---@type Tool
local class = Mod.getInfo('smc__core__tool').require('Tool')
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
---@return BaseUI
function Smc.requireBaseUI()
---@type BaseUI
local class = Mod.getInfo('smc__core__base_ui').require('BaseUI')
return class
end
---@return Formspec
function Smc.requireFormspec()
---@type Formspec
local class = Mod.getInfo('smc__core__formspec').require('Formspec')
return class
end

View File

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

View File

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

View File

@@ -0,0 +1,72 @@
local BaseUI, Formspec = Smc.requireBaseUI(), Smc.requireFormspec()
---@param self BaseUI
---@param playerName string
---@param isSelect boolean
---@return string
local function getFormSpecString(self, playerName, isSelect)
local items = {}
for name, def in pairs(core.registered_items) do
if def.groups and not def.groups.not_in_creative_inventory then
table.insert(items, name)
end
end
table.sort(items)
local listFormItems = Formspec:new()
local w, h = 0, 0
---@param name string
for _, name in ipairs(items) do
listFormItems:itemImageButton(w, h, 1, 1, name, name..'::item_button')
w = w + 1
if w >= 9 then
w = 0
h = h + 1
end
end
local listForm = Formspec:new({
size = {x=21, y=12},
})
listForm:
list('current_player', 'main', 10.5, 6.5, 8, 4):
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', self:getContex(playerName, 'scroll'))
if isSelect then
---@type ItemStackString
local item = self:getContex(playerName, 'select_item')
local itemDef = core.registered_items[item]
listForm:
itemImage(11, 0.5, 2, 2, item):
areaLabel(11, 4.5, 4, 1, 'Add to inventory:'):
button(11, 5, 3, 1, 'admin_commands:list_add_item', '1'):
button(14, 5,3, 1, 'admin_commands:list_add_item', ''..tostring(itemDef.stack_max)):
areaLabel(14.5, 0.5, 6, 4,
item..'\n\n'..
itemDef._title..'\n'..
itemDef._description)
end
return listForm:toString()
end
---@class AdminListUI : BaseUI
---@field getFormSpecString fun(self:BaseUI,playerName:string,isSelect:boolean):string
---@field showForm fun(self:BaseUI,playerName:string,isSelect:boolean):string
local AdminListUI = BaseUI:new('admin_commands:list_form', getFormSpecString)
AdminListUI:registerOnFormFieldAction('admin_commands:list_items', function(player, fieldName, fieldValue)
local scrollValue = string.match(fieldValue, 'CHG:(%S+)')
if scrollValue then
AdminListUI:setContex(player, 'scroll', scrollValue)
end
end)
return AdminListUI

View File

@@ -1,11 +1,4 @@
local modInfo = Mod.getInfo('smc__core__formspec')
local require = modInfo.require
---@type Formspec
local Formspec = require('Formspec')
---@type BaseUI
local BaseUI = Mod.getInfo('smc__core__base_ui').require('BaseUI')
local BaseUI, Formspec = Smc.requireBaseUI(), Smc.requireFormspec()
---@param self BaseUI
---@param playerName string