Compare commits
25 Commits
craft-syst
...
2813d9d5fe
| Author | SHA1 | Date | |
|---|---|---|---|
| 2813d9d5fe | |||
| 652200f28c | |||
| eeffae6852 | |||
| fe3298d112 | |||
| 7d49bbf535 | |||
| efcbc909e0 | |||
| 17413df9c4 | |||
| 2eede05436 | |||
| b863c88838 | |||
| 692105abfa | |||
| 1a6086190e | |||
| e20c3b4ef4 | |||
| 8b55ccff72 | |||
| c7cfe26335 | |||
| 51e6763457 | |||
| c47ab6ac3c | |||
| 6fd8295500 | |||
| b12f890740 | |||
| 4c90041c68 | |||
| b50d642bcf | |||
| e0b9024458 | |||
| 745eaa8569 | |||
| b6051e5724 | |||
| 5c936025f1 | |||
| 5be847bf58 |
@@ -10,18 +10,26 @@ local BaseUI = {
|
|||||||
contex = {}
|
contex = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param name string
|
---@param name string The name of the formspec that will be shown to the player. It is recommended that the name be unique.
|
||||||
---@param getFormSpecString fun(self:BaseUI,playerName:string,...):string
|
---@param getFormSpecString fun(self:BaseUI,playerName:string,...):string
|
||||||
function BaseUI:new(name, getFormSpecString)
|
---@param clearContex boolean? Whether to clear the context stored for a player when that player closes the form. Default `true`.
|
||||||
|
function BaseUI:new(name, getFormSpecString, clearContex)
|
||||||
|
if clearContex == nil then
|
||||||
|
clearContex = true
|
||||||
|
end
|
||||||
|
|
||||||
---@type BaseUI
|
---@type BaseUI
|
||||||
local instance = getInstance(self, {})
|
local instance = getInstance(self, {})
|
||||||
instance.name = name
|
instance.name = name
|
||||||
instance.getFormSpecString = getFormSpecString
|
instance.getFormSpecString = getFormSpecString
|
||||||
|
|
||||||
-- Ensure that when the form is closed, the context is cleared.
|
if clearContex then
|
||||||
instance:registerOnFormQuit(function(player)
|
core.log(name)
|
||||||
instance:clearContex(player)
|
-- Ensure that when the form is closed, the context is cleared.
|
||||||
end)
|
instance:registerOnFormQuit(function(player)
|
||||||
|
instance:clearContex(player)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -106,10 +106,10 @@ 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: '..
|
||||||
'complete or cancel active crafts to start a new one')
|
'complete or cancel active crafts to start a new one')
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -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.
|
||||||
|
|||||||
@@ -3,6 +3,20 @@ local posToString, getSize = core.pos_to_string, table.get_size
|
|||||||
local CRAFT_LIMIT_PER_PLAYER = 2
|
local CRAFT_LIMIT_PER_PLAYER = 2
|
||||||
local CRAFT_LIMIT_PER_SERVER = 10
|
local CRAFT_LIMIT_PER_SERVER = 10
|
||||||
|
|
||||||
|
local modStorage = core.get_mod_storage()
|
||||||
|
|
||||||
|
---@param key string
|
||||||
|
---@return table
|
||||||
|
local function getStorageTable(key)
|
||||||
|
return core.deserialize(modStorage:get_string(key)) or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param key string
|
||||||
|
---@param t table
|
||||||
|
local function setStorageTable(key, t)
|
||||||
|
modStorage:set_string(key, core.serialize(t))
|
||||||
|
end
|
||||||
|
|
||||||
---Designed to keep track of active immersive
|
---Designed to keep track of active immersive
|
||||||
---crafts so as not to overload the server.
|
---crafts so as not to overload the server.
|
||||||
---
|
---
|
||||||
@@ -12,18 +26,17 @@ local CRAFT_LIMIT_PER_SERVER = 10
|
|||||||
---@field craftsCountForPlayers table<string, table<string, boolean>>
|
---@field craftsCountForPlayers table<string, table<string, boolean>>
|
||||||
---@field craftsCountForServer table<string, boolean>
|
---@field craftsCountForServer table<string, boolean>
|
||||||
local ImmersiveCraftCounter = {
|
local ImmersiveCraftCounter = {
|
||||||
craftsCountForPlayers = {},
|
craftsCountForPlayers = getStorageTable('crafts_count_for_players'),
|
||||||
craftsCountForServer = {}
|
craftsCountForServer = getStorageTable('crafts_count_for_serves')
|
||||||
}
|
}
|
||||||
|
|
||||||
---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 +57,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
|
||||||
@@ -57,6 +70,9 @@ function ImmersiveCraftCounter:removeCraft(pos, Player)
|
|||||||
self.craftsCountForServer[posString] = nil
|
self.craftsCountForServer[posString] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: сделать сохранение данных во время перезагрузки сервера
|
core.register_on_shutdown(function()
|
||||||
|
setStorageTable('crafts_count_for_players', ImmersiveCraftCounter.craftsCountForPlayers)
|
||||||
|
setStorageTable('crafts_count_for_server', ImmersiveCraftCounter.craftsCountForServer)
|
||||||
|
end)
|
||||||
|
|
||||||
return ImmersiveCraftCounter
|
return ImmersiveCraftCounter
|
||||||
|
|||||||
@@ -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 = '',
|
||||||
|
|||||||
@@ -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[]?
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -37,7 +34,7 @@ local RARITY_INDEX = {
|
|||||||
---@class Item
|
---@class Item
|
||||||
---@field itemDef Item.ItemDefinition
|
---@field itemDef Item.ItemDefinition
|
||||||
---@field luantiDef ItemDefinition
|
---@field luantiDef ItemDefinition
|
||||||
---@field getVisual fun(): string
|
---@field getType fun():string
|
||||||
---@field defaultDef Item.ItemDefinition
|
---@field defaultDef Item.ItemDefinition
|
||||||
local Item = {
|
local Item = {
|
||||||
defaultDef = {
|
defaultDef = {
|
||||||
@@ -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 = {}
|
||||||
}
|
}
|
||||||
@@ -87,12 +85,10 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
local modName = Mod.getInfo().shortName
|
local modName = Mod.getInfo().shortName
|
||||||
local S = core.get_translator(modName)
|
local S = core.get_translator(modName)
|
||||||
|
|
||||||
itemDef = tableCopy(itemDef)
|
|
||||||
local s = itemDef.settings
|
local s = itemDef.settings
|
||||||
local c = itemDef.callbacks
|
local c = itemDef.callbacks
|
||||||
|
|
||||||
local title = s._title
|
local title, description = s._title, s._description
|
||||||
local description = s._description
|
|
||||||
|
|
||||||
if title == nil or title == '' then
|
if title == nil or title == '' then
|
||||||
title = string.match(s.name, '%S:(%S+)')..'-title'
|
title = string.match(s.name, '%S:(%S+)')..'-title'
|
||||||
@@ -102,9 +98,11 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local titleTranslate, descriptionTranslate = S(title), S(description)
|
||||||
|
|
||||||
if s._title_color ~= nil and s._description_color ~= nil then
|
if s._title_color ~= nil and s._description_color ~= nil then
|
||||||
title = colorize(s._title_color ,S(title))
|
titleTranslate = colorize(s._title_color , titleTranslate)
|
||||||
description = colorize(s._description_color, S(description))
|
descriptionTranslate = colorize(s._description_color, descriptionTranslate)
|
||||||
else
|
else
|
||||||
error('Item description color parameters cannot be empty.')
|
error('Item description color parameters cannot be empty.')
|
||||||
end
|
end
|
||||||
@@ -123,7 +121,7 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param luantiDef NodeDefinition
|
---@param luantiDef NodeDefinition
|
||||||
local function register3dItem(luantiDef)
|
local function registerNode(luantiDef)
|
||||||
local name = luantiDef.name
|
local name = luantiDef.name
|
||||||
luantiDef.name = nil
|
luantiDef.name = nil
|
||||||
|
|
||||||
@@ -131,13 +129,21 @@ local function register3dItem(luantiDef)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param luantiDef ItemDefinition
|
---@param luantiDef ItemDefinition
|
||||||
local function registerFlatItem(luantiDef)
|
local function registerCraftitem(luantiDef)
|
||||||
local name = luantiDef.name
|
local name = luantiDef.name
|
||||||
luantiDef.name = nil
|
luantiDef.name = nil
|
||||||
|
|
||||||
core.register_craftitem(':'..name, luantiDef)
|
core.register_craftitem(':'..name, luantiDef)
|
||||||
end
|
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
|
---The alias `table.merge` for EmmyLua
|
||||||
---@type fun(...):(Item.ItemDefinition)
|
---@type fun(...):(Item.ItemDefinition)
|
||||||
local defMerge = function(...)
|
local defMerge = function(...)
|
||||||
@@ -152,40 +158,48 @@ function Item:new(itemDef)
|
|||||||
'Please note that the `description` field should not be used when registering an item. '..
|
'Please note that the `description` field should not be used when registering an item. '..
|
||||||
'Use `_title` and `_description` instead.')
|
'Use `_title` and `_description` instead.')
|
||||||
|
|
||||||
|
itemDef = tableCopy(itemDef)
|
||||||
|
|
||||||
-- Adding default parameters
|
-- Adding default parameters
|
||||||
itemDef = defMerge(itemDef, self.defaultDef, true)
|
itemDef = defMerge(itemDef, self.defaultDef, true)
|
||||||
local s = itemDef.settings
|
local s = itemDef.settings
|
||||||
|
|
||||||
|
local shortModName = Mod.getInfo().shortName
|
||||||
|
|
||||||
if s._add_mod_name then
|
if s._add_mod_name then
|
||||||
s.name = Mod.getInfo().shortName .. ':' .. s.name
|
s.name = shortModName .. ':' .. s.name
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type Item
|
---@type Item
|
||||||
local instance = getInstance(self, {})
|
local instance = getInstance(self, {})
|
||||||
|
|
||||||
local luantiDef = itemDefToLuantiDef(itemDef)
|
local luantiDef = itemDefToLuantiDef(itemDef)
|
||||||
local visual = itemDef.settings._visual
|
local type = itemDef.settings._type
|
||||||
|
|
||||||
if visual == nil then
|
if type == nil then
|
||||||
visual = 'item_2d'
|
type = 'craftitem'
|
||||||
end
|
end
|
||||||
|
|
||||||
itemDef.settings._visual = nil
|
itemDef.settings._type = nil
|
||||||
|
|
||||||
if visual == 'item_3d' then
|
if type == 'node' then
|
||||||
register3dItem(luantiDef)
|
registerNode(luantiDef)
|
||||||
|
elseif type == 'craftitem' then
|
||||||
|
registerCraftitem(luantiDef)
|
||||||
|
elseif type == 'tool' then
|
||||||
|
registerTool(luantiDef)
|
||||||
else
|
else
|
||||||
visual = 'item_2d'
|
error(('Unknown item type: `%s`.'):format(type))
|
||||||
registerFlatItem(luantiDef)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function instance:getVisual()
|
function instance:getType()
|
||||||
return visual
|
return type
|
||||||
end
|
end
|
||||||
|
|
||||||
instance.itemDef = itemDef
|
instance.itemDef = itemDef
|
||||||
instance.luantiDef = luantiDef
|
instance.luantiDef = luantiDef
|
||||||
|
|
||||||
|
Smc.addRegisteredItem(shortModName, instance)
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -195,7 +209,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 +226,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
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ Settings._title_color = nil
|
|||||||
Settings._description_color = nil
|
Settings._description_color = nil
|
||||||
|
|
||||||
---Visual node type.
|
---Visual node type.
|
||||||
---@type Item.Visual?
|
---@type Item.Type?
|
||||||
Settings._visual = nil
|
Settings._type = nil
|
||||||
|
|
||||||
---Formal (lore) rarity of an item. Default `common`.
|
---Formal (lore) rarity of an item. Default `common`.
|
||||||
---@type Item.Rarity?
|
---@type Item.Rarity?
|
||||||
|
|||||||
1
mods/CORE/Item/src/Item/Type.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---@alias Item.Type 'craftitem'|'node'|'tool'
|
||||||
@@ -1 +0,0 @@
|
|||||||
---@alias Item.Visual 'item_2d'|'item_3d'
|
|
||||||
@@ -6,6 +6,8 @@ local getInstance = Class.getInstance
|
|||||||
local modInfo = Mod.getInfo('smc__core__map_gen')
|
local modInfo = Mod.getInfo('smc__core__map_gen')
|
||||||
local require = modInfo.require
|
local require = modInfo.require
|
||||||
|
|
||||||
|
---@alias MapGen.factors {height:number, temp:number, humidity:number}
|
||||||
|
|
||||||
---@alias MapGen.PastCalcNoiseValue {triangle:MapGen.Triangle?, x:integer?, z:integer?, noiseValue:number?}
|
---@alias MapGen.PastCalcNoiseValue {triangle:MapGen.Triangle?, x:integer?, z:integer?, noiseValue:number?}
|
||||||
|
|
||||||
---@type table<MapGen.Layer.Category, MapGen.PastCalcNoiseValue>
|
---@type table<MapGen.Layer.Category, MapGen.PastCalcNoiseValue>
|
||||||
@@ -649,26 +651,58 @@ end
|
|||||||
|
|
||||||
-- --- GENERATION METHODS ---
|
-- --- GENERATION METHODS ---
|
||||||
|
|
||||||
---The core logic of world generation. Determines which node type (water, rock, soil, air)
|
---@alias MapGen.nodeType 'AIR'|'WATER'|'CAVERN_AIR'|'TURF'|'SOIL'|'ROCK'|'BOTTOM'
|
||||||
---and which biome will be generated at the specified coordinates.
|
---@alias MapGen.postProcessingData {biome:MapGen.Biome, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType}
|
||||||
|
|
||||||
|
---@type table<number, MapGen.postProcessingData>
|
||||||
|
local postProcessing = {}
|
||||||
|
|
||||||
|
---@param biome MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param layer MapGen.Layer
|
---@param factors MapGen.factors
|
||||||
---@param height number
|
|
||||||
---@param temp number
|
|
||||||
---@param humidity number
|
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x integer
|
---@param x integer
|
||||||
---@param y integer
|
---@param y integer
|
||||||
---@param z integer
|
---@param z integer
|
||||||
local function generateNode(mapGenerator, layer, height, temp, humidity, data, index, x, y, z)
|
---@param nodeType MapGen.nodeType
|
||||||
|
local function addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, nodeType)
|
||||||
|
if biome.postProcessing == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
postProcessing[index] = {
|
||||||
|
biome = biome,
|
||||||
|
mapGenerator = mapGenerator,
|
||||||
|
factors = factors,
|
||||||
|
data = data,
|
||||||
|
index = index,
|
||||||
|
x = x,
|
||||||
|
y = y,
|
||||||
|
z = z,
|
||||||
|
nodeType = nodeType
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
---The core logic of world generation. Determines which node type (water, rock, soil, air)
|
||||||
|
---and which biome will be generated at the specified coordinates.
|
||||||
|
---@param mapGenerator MapGen
|
||||||
|
---@param layer MapGen.Layer
|
||||||
|
---@param factors MapGen.factors
|
||||||
|
---@param data number[]
|
||||||
|
---@param index number
|
||||||
|
---@param x integer
|
||||||
|
---@param y integer
|
||||||
|
---@param z integer
|
||||||
|
local function generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
local waterLevel = layer.waterLevel
|
local waterLevel = layer.waterLevel
|
||||||
|
local height, temp, humidity = factors.height, factors.temp, factors.humidity
|
||||||
|
|
||||||
-- Creating a rougher biome boundary.
|
-- Creating a rougher biome boundary.
|
||||||
local scatteringGorizontal = layer.biomesGorizontalScattering or 0
|
local scatteringGorizontal = layer.biomesGorizontalScattering or 0
|
||||||
local scatteringVertical = layer.biomesVerticalScattering or 0
|
local scatteringVertical = layer.biomesVerticalScattering or 0
|
||||||
local scattTemp = temp
|
local scattTemp = factors.temp
|
||||||
local scattHumidity = humidity
|
local scattHumidity = humidity
|
||||||
---@type number
|
---@type number
|
||||||
local scattHeight = y
|
local scattHeight = y
|
||||||
@@ -695,33 +729,39 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
|
|||||||
-- If the block is above surface height and above water level...
|
-- If the block is above surface height and above water level...
|
||||||
if y > height and y > waterLevel then
|
if y > height and y > waterLevel then
|
||||||
-- ... then airspace is generated.
|
-- ... then airspace is generated.
|
||||||
biome:generateAir(mapGenerator, data, index, x, y, z)
|
biome:generateAir(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'AIR')
|
||||||
|
|
||||||
-- If the block is above the surface height BUT below the water level...
|
-- If the block is above the surface height BUT below the water level...
|
||||||
elseif y > height and y <= waterLevel then
|
elseif y > height and y <= waterLevel then
|
||||||
-- ... then underwater space is generated.
|
-- ... then underwater space is generated.
|
||||||
biome:generateWater(mapGenerator, data, index, x, y, z)
|
biome:generateWater(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'WATER')
|
||||||
|
|
||||||
-- If the block is below the surface height...
|
-- If the block is below the surface height...
|
||||||
elseif y <= height then
|
elseif y <= height then
|
||||||
-- ... and a cavern is generated in the block...
|
-- ... and a cavern is generated in the block...
|
||||||
if mapGenerator:isCavern(layer, x, y, z) then
|
if mapGenerator:isCavern(layer, x, y, z) then
|
||||||
-- ... then airspace is generated.
|
-- ... then airspace is generated.
|
||||||
biome:generateCavernAir(mapGenerator, data, index, x, y, z)
|
biome:generateCavernAir(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'CAVERN_AIR')
|
||||||
|
|
||||||
-- ... or if the surface height is above the water level...
|
-- ... 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...
|
--- ... and the height of the block is equal to the height of the surface...
|
||||||
if y == height then
|
if y == height then
|
||||||
-- ... then turf is generated.
|
-- ... then turf is generated.
|
||||||
biome:generateTurf(mapGenerator, data, index, x, y, z)
|
biome:generateTurf(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'TURF')
|
||||||
-- ... or if the height of the block falls within the thickness of the soil layer...
|
-- ... or if the height of the block falls within the thickness of the soil layer...
|
||||||
elseif y > height - biome.soilHeight then
|
elseif y > height - biome.soilHeight then
|
||||||
-- ... then soil is generated.
|
-- ... then soil is generated.
|
||||||
biome:generateSoil(mapGenerator, data, index, x, y, z)
|
biome:generateSoil(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'SOIL')
|
||||||
else
|
else
|
||||||
-- ... else e a stone is generated.
|
-- ... else a stone is generated.
|
||||||
biome:generateRock(mapGenerator, data, index, x, y, z)
|
biome:generateRock(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'ROCK')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ... or if the surface height is below the water level...
|
-- ... or if the surface height is below the water level...
|
||||||
@@ -729,10 +769,12 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
|
|||||||
-- ... and if the height of the block falls within the thickness of the soil layer...
|
-- ... and if the height of the block falls within the thickness of the soil layer...
|
||||||
if y > height - biome.soilHeight then
|
if y > height - biome.soilHeight then
|
||||||
-- ... then the river/ocean bottom is generated.
|
-- ... then the river/ocean bottom is generated.
|
||||||
biome:generateBottom(mapGenerator, data, index, x, y, z)
|
biome:generateBottom(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'BOTTOM')
|
||||||
else
|
else
|
||||||
-- ... else a stone is generated.
|
-- ... else a stone is generated.
|
||||||
biome:generateRock(mapGenerator, data, index, x, y, z)
|
biome:generateRock(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'ROCK')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -1019,7 +1061,14 @@ local function generatorHandler(mapGenerator, data, index, x, y, z)
|
|||||||
noiseTempValue = layer:calcTemp(noiseTempValue, y)
|
noiseTempValue = layer:calcTemp(noiseTempValue, y)
|
||||||
noiseHumidityValue = layer:calcHumidity(noiseHumidityValue, y)
|
noiseHumidityValue = layer:calcHumidity(noiseHumidityValue, y)
|
||||||
|
|
||||||
generateNode(mapGenerator, layer, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z)
|
---@type MapGen.factors
|
||||||
|
local factors = {
|
||||||
|
height = noiseHeightValue,
|
||||||
|
temp = noiseTempValue,
|
||||||
|
humidity = noiseHumidityValue,
|
||||||
|
}
|
||||||
|
|
||||||
|
generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Chunk generation handler.
|
---Chunk generation handler.
|
||||||
@@ -1059,6 +1108,21 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Post-proccesing generation
|
||||||
|
for _, ppdata in pairs(postProcessing) do
|
||||||
|
if ppdata.biome.postProcessing ~= nil then
|
||||||
|
ppdata.biome:postProcessing(ppdata.mapGenerator,
|
||||||
|
ppdata.factors,
|
||||||
|
ppdata.data,
|
||||||
|
ppdata.index,
|
||||||
|
ppdata.x,
|
||||||
|
ppdata.y,
|
||||||
|
ppdata.z,
|
||||||
|
ppdata.nodeType,
|
||||||
|
area)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- We make changes back to LVM and recalculate light & liquids
|
-- We make changes back to LVM and recalculate light & liquids
|
||||||
voxelManip:set_data(data)
|
voxelManip:set_data(data)
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ local getInstance = Class.getInstance
|
|||||||
---@field generateTurf generateFunc
|
---@field generateTurf generateFunc
|
||||||
---@field generateSoil generateFunc
|
---@field generateSoil generateFunc
|
||||||
---@field generateBottom generateFunc
|
---@field generateBottom generateFunc
|
||||||
|
---@field postProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
||||||
local Biome = {}
|
local Biome = {}
|
||||||
|
|
||||||
---@alias generateFunc fun(self, mapGenerator:MapGen, data:number[], index:number, x:number, y:number, z:number)
|
---@alias generateFunc fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number)
|
||||||
|
|
||||||
---Definition table for the `MapGen.Biome`.
|
---Definition table for the `MapGen.Biome`.
|
||||||
---
|
---
|
||||||
@@ -39,84 +40,91 @@ local Biome = {}
|
|||||||
---@field generateTurf generateFunc?
|
---@field generateTurf generateFunc?
|
||||||
---@field generateSoil generateFunc?
|
---@field generateSoil generateFunc?
|
||||||
---@field generateBottom generateFunc?
|
---@field generateBottom generateFunc?
|
||||||
|
---@field postProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
||||||
|
|
||||||
-- Default generate functions
|
-- Default generate functions
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateAir = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateAir = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = mapGenerator.nodeIDs.air
|
data[index] = mapGenerator.nodeIDs.air
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateCavernAir = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateCavernAir = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
self:generateAir(mapGenerator, data, index, x, y, z)
|
self:generateAir(mapGenerator, factors, data, index, x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateWater = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateWater = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = mapGenerator.nodeIDs.water
|
data[index] = mapGenerator.nodeIDs.water
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateRock = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateRock = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.rock
|
data[index] = self.groundNodesIDs.rock
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateTurf = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateTurf = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.turf
|
data[index] = self.groundNodesIDs.turf
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateSoil = function(self, mapGenerator,data, index, x, y, z)
|
local defaultGenerateSoil = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.soil
|
data[index] = self.groundNodesIDs.soil
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateBottom = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateBottom = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.bottom
|
data[index] = self.groundNodesIDs.bottom
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -167,23 +175,23 @@ function Biome:new(name, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@type MapGen.Biome
|
---@type MapGen.Biome
|
||||||
local instance = getInstance(self, {
|
local instance = getInstance(self, {})
|
||||||
name = name,
|
instance.name = name
|
||||||
tempPoint = def.tempPoint,
|
instance.tempPoint = def.tempPoint
|
||||||
humidityPoint = def.humidityPoint,
|
instance.humidityPoint = def.humidityPoint
|
||||||
minY = def.minY,
|
instance.minY = def.minY
|
||||||
maxY = def.maxY,
|
instance.maxY = def.maxY
|
||||||
groundNodes = def.groundNodes,
|
instance.groundNodes = def.groundNodes
|
||||||
groundNodesIDs = groundNodesIDs,
|
instance.groundNodesIDs = groundNodesIDs
|
||||||
soilHeight = def.soilHeight,
|
instance.soilHeight = def.soilHeight
|
||||||
generateAir = def.generateAir,
|
instance.generateAir = def.generateAir
|
||||||
generateCavernAir = def.generateCavernAir,
|
instance.generateCavernAir = def.generateCavernAir
|
||||||
generateWater = def.generateWater,
|
instance.generateWater = def.generateWater
|
||||||
generateRock = def.generateRock,
|
instance.generateRock = def.generateRock
|
||||||
generateSoil = def.generateSoil,
|
instance.generateSoil = def.generateSoil
|
||||||
generateTurf = def.generateTurf,
|
instance.generateTurf = def.generateTurf
|
||||||
generateBottom = def.generateBottom,
|
instance.generateBottom = def.generateBottom
|
||||||
})
|
instance.postProcessing = def.postProcessing
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ local getInstance = Class.getInstance
|
|||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field staticNode string
|
---@field staticNode string
|
||||||
---@field staticNodeID number
|
---@field staticNodeID number
|
||||||
---@field generateStaticNode generateFunc
|
---@field generateStaticNode fun(self, mapGenerator:MapGen, data:number[], index:number, x:number, y:number, z:number)
|
||||||
local StaticLayer = {}
|
local StaticLayer = {}
|
||||||
|
|
||||||
---Definition table for the `MapGen.StaticLayer`.
|
---Definition table for the `MapGen.StaticLayer`.
|
||||||
@@ -18,7 +18,7 @@ local StaticLayer = {}
|
|||||||
---@field minY number
|
---@field minY number
|
||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field staticNode string
|
---@field staticNode string
|
||||||
---@field generateStaticNode generateFunc
|
---@field generateStaticNode fun(self, mapGenerator:MapGen, data:number[], index:number, x:number, y:number, z:number)
|
||||||
|
|
||||||
---@param self MapGen.StaticLayer
|
---@param self MapGen.StaticLayer
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -22,7 +16,7 @@ function Node:new(nodeDef)
|
|||||||
---Adding default parameters
|
---Adding default parameters
|
||||||
nodeDef = defMerge(nodeDef, self.defaultDef, true)
|
nodeDef = defMerge(nodeDef, self.defaultDef, true)
|
||||||
|
|
||||||
nodeDef.settings._visual = 'item_3d'
|
nodeDef.settings._type = 'node'
|
||||||
|
|
||||||
---@type Node
|
---@type Node
|
||||||
local instance = Item:new(nodeDef)
|
local instance = Item:new(nodeDef)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
4
mods/CORE/Tool/init.lua
Normal 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
@@ -0,0 +1,2 @@
|
|||||||
|
name = smc__core__tool
|
||||||
|
depends = smc__core__item
|
||||||
70
mods/CORE/Tool/src/Tool.lua
Normal 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
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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)
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
name = smc__core__admin_commands
|
|
||||||
depends = smc__system__system_loader, smc__core__formspec, smc__core__item
|
|
||||||
@@ -214,7 +214,7 @@ local rocksNoiseParams ={
|
|||||||
lacunarity = 4,
|
lacunarity = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function generateRock(biome, mapGenerator, data, index, x, y, z)
|
local function generateRock(biome, mapGenerator, factors, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
|
|
||||||
if rocksNoise == nil then
|
if rocksNoise == nil then
|
||||||
@@ -249,7 +249,7 @@ local function generateRock(biome, mapGenerator, data, index, x, y, z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param biome MapGen.Biome
|
---@param biome MapGen.Biome
|
||||||
local function generateSoil(biome, mapGenerator, data, index, x, y, z)
|
local function generateSoil(biome, mapGenerator, factors, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
if rocksNoise == nil then
|
if rocksNoise == nil then
|
||||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||||
@@ -269,7 +269,7 @@ local function generateSoil(biome, mapGenerator, data, index, x, y, z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param biome MapGen.Biome
|
---@param biome MapGen.Biome
|
||||||
local function generateTurf(biome, mapGenerator, data, index, x, y, z)
|
local function generateTurf(biome, mapGenerator, factors, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
if rocksNoise == nil then
|
if rocksNoise == nil then
|
||||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||||
@@ -288,6 +288,22 @@ local function generateTurf(biome, mapGenerator, data, index, x, y, z)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param area VoxelArea
|
||||||
|
local function postProcessing(biome, mapGenerator, factors, data, index, x, y, z, nodeType, area)
|
||||||
|
local trufID = biome.groundNodesIDs.turf
|
||||||
|
local waterID = mapGenerator.nodeIDs.water
|
||||||
|
if data[index] ~= trufID then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if (data[area:index(x+1, y, z)] == trufID or data[area:index(x+1, y, z)] == waterID) and
|
||||||
|
(data[area:index(x-1, y, z)] == trufID or data[area:index(x-1, y, z)] == waterID) and
|
||||||
|
(data[area:index(x, y, z+1)] == trufID or data[area:index(x, y, z+1)] == waterID) and
|
||||||
|
(data[area:index(x, y, z-1)] == trufID or data[area:index(x, y, z-1)] == waterID) then
|
||||||
|
data[index] = mapGenerator.nodeIDs.water
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
mapGenerator:registerBiome('midgard', 'swamp', {
|
mapGenerator:registerBiome('midgard', 'swamp', {
|
||||||
tempPoint = 0,
|
tempPoint = 0,
|
||||||
humidityPoint = 80,
|
humidityPoint = 80,
|
||||||
@@ -303,6 +319,7 @@ mapGenerator:registerBiome('midgard', 'swamp', {
|
|||||||
generateRock = generateRock,
|
generateRock = generateRock,
|
||||||
generateTurf = generateTurf,
|
generateTurf = generateTurf,
|
||||||
generateSoil = generateSoil,
|
generateSoil = generateSoil,
|
||||||
|
postProcessing = postProcessing
|
||||||
})
|
})
|
||||||
|
|
||||||
return mapGenerator
|
return mapGenerator
|
||||||
@@ -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
|
||||||
|
|||||||
35
mods/GAME/ITEMS/essences/init.lua
Normal 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)
|
||||||
|
}
|
||||||
|
})
|
||||||
10
mods/GAME/ITEMS/essences/locale/essences.ru.tr
Normal 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заключающий в себе жизненную энергию.
|
||||||
2
mods/GAME/ITEMS/essences/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
name = smc__game__items__essences
|
||||||
|
depends = smc__core__item
|
||||||
BIN
mods/GAME/ITEMS/essences/textures/sheets/essences_sheet.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
@@ -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 = {
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -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 = {
|
||||||
@@ -59,6 +55,8 @@ local function registerPilarStaff(rock, y)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
registerPilarStaff('sylite', 0)
|
||||||
|
registerPilarStaff('sylite_gray', 1)
|
||||||
registerPilarStaff('sylite_black', 2)
|
registerPilarStaff('sylite_black', 2)
|
||||||
|
|
||||||
registerRocksTypes('', 0)
|
registerRocksTypes('', 0)
|
||||||
@@ -66,81 +64,3 @@ registerRocksTypes('_chipped', 1)
|
|||||||
registerRocksTypes('_block', 3)
|
registerRocksTypes('_block', 3)
|
||||||
registerRocksTypes('_bricks', 4)
|
registerRocksTypes('_bricks', 4)
|
||||||
registerRocksTypes('_bricks_2', 5)
|
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"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
--]]
|
|
||||||
|
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 151 KiB |
@@ -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'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
99
mods/GAME/ITEMS/storages/init.lua
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
|
||||||
|
|
||||||
|
local defaultStorage = Node:getExtended({
|
||||||
|
settings = {
|
||||||
|
name = '',
|
||||||
|
groups = {
|
||||||
|
dig_immediate = 2,
|
||||||
|
storage = 1
|
||||||
|
},
|
||||||
|
paramtype = 'light',
|
||||||
|
paramtype2 = 'facedir',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
local storageFactory = defaultStorage:getFactory()
|
||||||
|
|
||||||
|
---@type TileSheet
|
||||||
|
local caseTileSheet = TileSheet:new('cases_sheet.png', 16, 16)
|
||||||
|
|
||||||
|
local function getCaseTiles(x, y)
|
||||||
|
return {
|
||||||
|
caseTileSheet:t(x, y),
|
||||||
|
caseTileSheet:t(x, y),
|
||||||
|
caseTileSheet:t(x, y+1),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local t = getCaseTiles
|
||||||
|
|
||||||
|
storageFactory:registerItems({
|
||||||
|
---@type Node.NodeDefinition
|
||||||
|
{
|
||||||
|
settings = {
|
||||||
|
name = 'case_closed',
|
||||||
|
_title = 'Case',
|
||||||
|
--description = '',
|
||||||
|
tiles = t(0,0)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
---@type Node.NodeDefinition
|
||||||
|
{
|
||||||
|
settings = {
|
||||||
|
name = 'case_open',
|
||||||
|
_title = 'Case',
|
||||||
|
--description = '',
|
||||||
|
tiles = t(1,0);
|
||||||
|
drawtype = 'nodebox';
|
||||||
|
node_box = {
|
||||||
|
type = 'fixed',
|
||||||
|
fixed = {
|
||||||
|
{-0.5, -0.5, -0.5, 0.5, 0.5 - 1/16*2, 0.5},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
---@type Node.NodeDefinition
|
||||||
|
{
|
||||||
|
settings = {
|
||||||
|
drawtype = 'mesh',
|
||||||
|
name = 'chest_close',
|
||||||
|
tiles = {'storage_chest.png'},
|
||||||
|
mesh = 'storage_chest_close.obj',
|
||||||
|
node_box = {
|
||||||
|
type = 'fixed',
|
||||||
|
fixed = {
|
||||||
|
{-7/16, -0.5, -7/16, 23/16, 6/16, 7/16},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = 'fixed',
|
||||||
|
fixed = {
|
||||||
|
{-7/16, -0.5, -7/16, 23/16, 6/16, 7/16},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
---@type Node.NodeDefinition
|
||||||
|
{
|
||||||
|
settings = {
|
||||||
|
drawtype = 'mesh',
|
||||||
|
name = 'chest_open',
|
||||||
|
tiles = {'storage_chest.png'},
|
||||||
|
mesh = 'storage_chest_open.obj',
|
||||||
|
node_box = {
|
||||||
|
type = 'fixed',
|
||||||
|
fixed = {
|
||||||
|
{-7/16, -0.5, -7/16, 23/16, 6/16, 7/16},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = 'fixed',
|
||||||
|
fixed = {
|
||||||
|
{-7/16, -0.5, -7/16, 23/16, 6/16, 7/16},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
2
mods/GAME/ITEMS/storages/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
name = smc__game__items__storages
|
||||||
|
depends = smc__core__node, smc__core__tilesheet
|
||||||
49
mods/GAME/ITEMS/storages/models/storage_chest_close.obj
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# Made in Blockbench 4.12.5
|
||||||
|
mtllib storage_chest_close.mtl
|
||||||
|
|
||||||
|
o chest_close
|
||||||
|
v 0.4375 0.375 0.4375
|
||||||
|
v 0.4375 0.375 -0.4375
|
||||||
|
v 0.4375 -0.5 0.4375
|
||||||
|
v 0.4375 -0.5 -0.4375
|
||||||
|
v -1.4375 0.375 -0.4375
|
||||||
|
v -1.4375 0.375 0.4375
|
||||||
|
v -1.4375 -0.5 -0.4375
|
||||||
|
v -1.4375 -0.5 0.4375
|
||||||
|
vt 0.109375 0.890625
|
||||||
|
vt 0.34375 0.890625
|
||||||
|
vt 0.34375 0.78125
|
||||||
|
vt 0.109375 0.78125
|
||||||
|
vt 0 0.890625
|
||||||
|
vt 0.109375 0.890625
|
||||||
|
vt 0.109375 0.78125
|
||||||
|
vt 0 0.78125
|
||||||
|
vt 0.453125 0.890625
|
||||||
|
vt 0.6875 0.890625
|
||||||
|
vt 0.6875 0.78125
|
||||||
|
vt 0.453125 0.78125
|
||||||
|
vt 0.34375 0.890625
|
||||||
|
vt 0.453125 0.890625
|
||||||
|
vt 0.453125 0.78125
|
||||||
|
vt 0.34375 0.78125
|
||||||
|
vt 0.34375 0.890625
|
||||||
|
vt 0.109375 0.890625
|
||||||
|
vt 0.109375 1
|
||||||
|
vt 0.34375 1
|
||||||
|
vt 0.578125 1
|
||||||
|
vt 0.34375 1
|
||||||
|
vt 0.34375 0.890625
|
||||||
|
vt 0.578125 0.890625
|
||||||
|
vn 0 0 -1
|
||||||
|
vn 1 0 0
|
||||||
|
vn 0 0 1
|
||||||
|
vn -1 0 0
|
||||||
|
vn 0 1 0
|
||||||
|
vn 0 -1 0
|
||||||
|
usemtl m_79b8a0d4-4f5c-1950-bda6-ec259f602f6d
|
||||||
|
f 4/4/1 7/3/1 5/2/1 2/1/1
|
||||||
|
f 3/8/2 4/7/2 2/6/2 1/5/2
|
||||||
|
f 8/12/3 3/11/3 1/10/3 6/9/3
|
||||||
|
f 7/16/4 8/15/4 6/14/4 5/13/4
|
||||||
|
f 6/20/5 1/19/5 2/18/5 5/17/5
|
||||||
|
f 7/24/6 4/23/6 3/22/6 8/21/6
|
||||||
95
mods/GAME/ITEMS/storages/models/storage_chest_open.obj
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
# Made in Blockbench 4.12.5
|
||||||
|
mtllib storage_chest_open.mtl
|
||||||
|
|
||||||
|
o сундук
|
||||||
|
v 0.4375 0.25 0.4375
|
||||||
|
v 0.4375 0.25 -0.4375
|
||||||
|
v 0.4375 -0.5 0.4375
|
||||||
|
v 0.4375 -0.5 -0.4375
|
||||||
|
v -1.4375 0.25 -0.4375
|
||||||
|
v -1.4375 0.25 0.4375
|
||||||
|
v -1.4375 -0.5 -0.4375
|
||||||
|
v -1.4375 -0.5 0.4375
|
||||||
|
vt 0.109375 0.875
|
||||||
|
vt 0.34375 0.875
|
||||||
|
vt 0.34375 0.78125
|
||||||
|
vt 0.109375 0.78125
|
||||||
|
vt 0 0.875
|
||||||
|
vt 0.109375 0.875
|
||||||
|
vt 0.109375 0.78125
|
||||||
|
vt 0 0.78125
|
||||||
|
vt 0.453125 0.875
|
||||||
|
vt 0.6875 0.875
|
||||||
|
vt 0.6875 0.78125
|
||||||
|
vt 0.453125 0.78125
|
||||||
|
vt 0.34375 0.875
|
||||||
|
vt 0.453125 0.875
|
||||||
|
vt 0.453125 0.78125
|
||||||
|
vt 0.34375 0.78125
|
||||||
|
vt 0.8125 0.890625
|
||||||
|
vt 0.578125 0.890625
|
||||||
|
vt 0.578125 1
|
||||||
|
vt 0.8125 1
|
||||||
|
vt 0.578125 1
|
||||||
|
vt 0.34375 1
|
||||||
|
vt 0.34375 0.890625
|
||||||
|
vt 0.578125 0.890625
|
||||||
|
vn 0 0 -1
|
||||||
|
vn 1 0 0
|
||||||
|
vn 0 0 1
|
||||||
|
vn -1 0 0
|
||||||
|
vn 0 1 0
|
||||||
|
vn 0 -1 0
|
||||||
|
usemtl m_79b8a0d4-4f5c-1950-bda6-ec259f602f6d
|
||||||
|
f 4/4/1 7/3/1 5/2/1 2/1/1
|
||||||
|
f 3/8/2 4/7/2 2/6/2 1/5/2
|
||||||
|
f 8/12/3 3/11/3 1/10/3 6/9/3
|
||||||
|
f 7/16/4 8/15/4 6/14/4 5/13/4
|
||||||
|
f 6/20/5 1/19/5 2/18/5 5/17/5
|
||||||
|
f 7/24/6 4/23/6 3/22/6 8/21/6
|
||||||
|
o крышка
|
||||||
|
v 0.4375 0.33838834764831843 0.46338834764831843
|
||||||
|
v 0.4375 0.9571067811865475 -0.15533008588991049
|
||||||
|
v 0.4375 0.25 0.375
|
||||||
|
v 0.4375 0.8687184335382291 -0.24371843353822897
|
||||||
|
v -1.4375 0.9571067811865475 -0.15533008588991049
|
||||||
|
v -1.4375 0.33838834764831843 0.46338834764831843
|
||||||
|
v -1.4375 0.8687184335382291 -0.24371843353822897
|
||||||
|
v -1.4375 0.25 0.375
|
||||||
|
vt 0.109375 0.890625
|
||||||
|
vt 0.34375 0.890625
|
||||||
|
vt 0.34375 0.875
|
||||||
|
vt 0.109375 0.875
|
||||||
|
vt 0 0.890625
|
||||||
|
vt 0.109375 0.890625
|
||||||
|
vt 0.109375 0.875
|
||||||
|
vt 0 0.875
|
||||||
|
vt 0.453125 0.890625
|
||||||
|
vt 0.6875 0.890625
|
||||||
|
vt 0.6875 0.875
|
||||||
|
vt 0.453125 0.875
|
||||||
|
vt 0.34375 0.890625
|
||||||
|
vt 0.453125 0.890625
|
||||||
|
vt 0.453125 0.875
|
||||||
|
vt 0.34375 0.875
|
||||||
|
vt 0.34375 0.890625
|
||||||
|
vt 0.109375 0.890625
|
||||||
|
vt 0.109375 1
|
||||||
|
vt 0.34375 1
|
||||||
|
vt 0.578125 1
|
||||||
|
vt 0.34375 1
|
||||||
|
vt 0.34375 0.890625
|
||||||
|
vt 0.578125 0.890625
|
||||||
|
vn 0 0.7071067811865476 -0.7071067811865475
|
||||||
|
vn 1 0 0
|
||||||
|
vn 0 -0.7071067811865476 0.7071067811865475
|
||||||
|
vn -1 0 0
|
||||||
|
vn 0 0.7071067811865475 0.7071067811865476
|
||||||
|
vn 0 -0.7071067811865475 -0.7071067811865476
|
||||||
|
usemtl m_79b8a0d4-4f5c-1950-bda6-ec259f602f6d
|
||||||
|
f 12/28/7 15/27/7 13/26/7 10/25/7
|
||||||
|
f 11/32/8 12/31/8 10/30/8 9/29/8
|
||||||
|
f 16/36/9 11/35/9 9/34/9 14/33/9
|
||||||
|
f 15/40/10 16/39/10 14/38/10 13/37/10
|
||||||
|
f 14/44/11 9/43/11 10/42/11 13/41/11
|
||||||
|
f 15/48/12 12/47/12 11/46/12 16/45/12
|
||||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
BIN
mods/GAME/ITEMS/storages/textures/storage_chest.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
@@ -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,161 +58,129 @@ 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, 2),
|
||||||
--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..'_log_stripped',
|
||||||
_title = "Marentine Planks",
|
tiles = getLogTiles(x, 4),
|
||||||
--description = "",
|
paramtype2 = 'facedir',
|
||||||
tiles = { logTileSheet:t(0, 4) },
|
|
||||||
},
|
},
|
||||||
},
|
callbacks = {
|
||||||
---@type Node.NodeDefinition
|
on_place = core.rotate_node
|
||||||
{
|
}
|
||||||
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) },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- сундучки
|
defaultLog:new({
|
||||||
|
settings = {
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
callbacks = {
|
||||||
|
on_place = core.rotate_node
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
---@type TileSheet
|
defaultLog:new({
|
||||||
local caseTileSheet = TileSheet:new("cases_sheet.png", 16, 16)
|
settings = {
|
||||||
|
name = name..'_trunk',
|
||||||
|
tiles = {logTileSheet:t(x, 3)},
|
||||||
|
inventory_overlay = 'wood_trunk_overlay.png',
|
||||||
|
drop = 'wood:'..name..'_log',
|
||||||
|
paramtype2 = 'facedir',
|
||||||
|
},
|
||||||
|
callbacks = {
|
||||||
|
on_place = core.rotate_node
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
local function getCaseTiles(x, y)
|
defaultLog:new({
|
||||||
return {
|
settings = {
|
||||||
caseTileSheet:t(x, y),
|
name = name..'_trunk_vertical',
|
||||||
caseTileSheet:t(x, y),
|
tiles = getLogTiles(x, 2),
|
||||||
caseTileSheet:t(x, y+1),
|
inventory_overlay = 'wood_trunk_overlay.png',
|
||||||
}
|
drop = 'wood:'..name..'_log',
|
||||||
|
paramtype2 = 'facedir',
|
||||||
|
},
|
||||||
|
callbacks = {
|
||||||
|
on_place = core.rotate_node
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
defaultLog:new({
|
||||||
|
settings = {
|
||||||
|
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'}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
defaultLog:new({
|
||||||
|
settings = {
|
||||||
|
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
|
end
|
||||||
|
|
||||||
local t = getCaseTiles
|
registerWood('marentine', 0)
|
||||||
|
registerWood('allwhere', 1)
|
||||||
planksFactory:registerItems({
|
registerWood('fis', 2)
|
||||||
---@type Node.NodeDefinition
|
registerWood('tammoy', 3)
|
||||||
{
|
registerWood('gi', 4)
|
||||||
settings = {
|
registerWood('dallalia', 5)
|
||||||
name = "case_closed",
|
registerWood('zuph', 6)
|
||||||
_title = "Case",
|
|
||||||
--description = "",
|
|
||||||
tiles = t(0,0)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
---@type Node.NodeDefinition
|
|
||||||
{
|
|
||||||
settings = {
|
|
||||||
name = "case_open",
|
|
||||||
_title = "Case",
|
|
||||||
--description = "",
|
|
||||||
tiles = t(1,0);
|
|
||||||
drawtype = 'nodebox';
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0.5 - 1/16*2, 0.5},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 16 KiB |
BIN
mods/GAME/ITEMS/wood/textures/wood_trunk_overlay.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
131
mods/GAME/adminCommands/init.lua
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
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)
|
||||||
|
|
||||||
|
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)
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
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)
|
||||||
|
|
||||||
|
-- Keys indicating the languages for which localization presence is checked.
|
||||||
|
local LANG_CODES = {'en', 'ru'}
|
||||||
|
|
||||||
|
-- Number of missed localizations.
|
||||||
|
local missedLocaleCount = 0
|
||||||
|
|
||||||
|
local function checkLocale(strTranslate, langCodes)
|
||||||
|
local str = core.strip_escapes(strTranslate)
|
||||||
|
|
||||||
|
for _, langCode in ipairs(langCodes or LANG_CODES) do
|
||||||
|
if core.strip_escapes(core.get_translated_string(langCode, strTranslate)) == str then
|
||||||
|
missedLocaleCount = missedLocaleCount + 1
|
||||||
|
Logger.warningLog('Localization missing[%s][%s]. String: `%s`.', missedLocaleCount, langCode, str)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
core.register_chatcommand('get_missing_locale', {
|
||||||
|
privs = {server = true},
|
||||||
|
description = '{short_mod_name:string?, lang_codes:string[]?}',
|
||||||
|
func = function(name, paramsStr)
|
||||||
|
local params = core.deserialize('return '..paramsStr or '{}')
|
||||||
|
|
||||||
|
if params == nil then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local shortModName = params.short_mod_name
|
||||||
|
local langCodes = params.lang_codes
|
||||||
|
|
||||||
|
if shortModName ~= nil and type(shortModName) ~= 'string' then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if langCodes ~= nil and type(langCodes) ~= 'table' then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local items
|
||||||
|
if shortModName == '' or shortModName == nil then
|
||||||
|
items = Smc.getRegisteredItems()
|
||||||
|
else
|
||||||
|
items = Smc.getRegisteredItemsByMod(shortModName)
|
||||||
|
end
|
||||||
|
|
||||||
|
if items == nil then
|
||||||
|
return false, 'There are no items registered for this mod (or the entire game)'
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param name string
|
||||||
|
---@param item Item
|
||||||
|
for name, item in pairs(items) do
|
||||||
|
local itemSettings = item.itemDef.settings
|
||||||
|
local title, desc = itemSettings._title, itemSettings._description
|
||||||
|
|
||||||
|
checkLocale(title, langCodes)
|
||||||
|
checkLocale(desc, langCodes)
|
||||||
|
end
|
||||||
|
|
||||||
|
return true, ''
|
||||||
|
end
|
||||||
|
})
|
||||||
2
mods/GAME/adminCommands/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
name = smc__game__admin_commands
|
||||||
|
depends = smc__system__system_loader, smc__ui__admin_list
|
||||||
BIN
mods/SYSTEM/HelperLib/fonts/Philosopher-Regular.ttf
Normal file
56
mods/SYSTEM/HelperLib/fonts/fonts.md
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Game fonts
|
||||||
|
Description of the fonts that are pre-installed for the project and passed on to all clients for displaying text.
|
||||||
|
|
||||||
|
## Philosopher
|
||||||
|
Download site: https://fonts-online.ru/fonts/doloto.
|
||||||
|
|
||||||
|
Used in:
|
||||||
|
- `regular.ttf`
|
||||||
|
- `mono.ttf`
|
||||||
|
|
||||||
|
### Info
|
||||||
|
Designed by **Jovanny Lemonad**.
|
||||||
|
|
||||||
|
### Licence
|
||||||
|
Copyright 2011 The Philosopher Project Authors (https://github.com/alexeiva/philosopher)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1 . This license is copied below, and is also available with a FAQ at: https://openfontlicense.org
|
||||||
|
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
|
||||||
|
#### PREAMBLE
|
||||||
|
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
#### DEFINITIONS
|
||||||
|
|
||||||
|
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
|
||||||
|
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
#### PERMISSION & CONDITIONS
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
|
||||||
|
|
||||||
|
- Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
|
||||||
|
- Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
|
||||||
|
- No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
|
||||||
|
- The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
|
||||||
|
- The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
|
||||||
|
|
||||||
|
#### TERMINATION
|
||||||
|
|
||||||
|
This license becomes null and void if any of the above conditions are not met.
|
||||||
|
|
||||||
|
#### DISCLAIMER
|
||||||
|
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
|
|
||||||
|
---
|
||||||
BIN
mods/SYSTEM/HelperLib/fonts/mono.ttf
Normal file
BIN
mods/SYSTEM/HelperLib/fonts/regular.ttf
Normal file
@@ -7,4 +7,6 @@ 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.registeredItems')
|
||||||
|
require('Lib.requires')
|
||||||
@@ -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
|
||||||
|
|||||||
33
mods/SYSTEM/HelperLib/src/Lib/registeredItems.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
---@type table<string, Item>
|
||||||
|
local registeredItems = {}
|
||||||
|
|
||||||
|
---@type table<string, table<string, Item>>
|
||||||
|
local registeredItemsByMod = {}
|
||||||
|
|
||||||
|
---@param shortModName string
|
||||||
|
---@param item Item
|
||||||
|
function Smc.addRegisteredItem(shortModName, item)
|
||||||
|
local itemName = item.itemDef.settings.name
|
||||||
|
local modItems = registeredItemsByMod[shortModName]
|
||||||
|
|
||||||
|
if modItems == nil then
|
||||||
|
registeredItemsByMod[shortModName] = {[itemName]=item}
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
assert(modItems[itemName] == nil)
|
||||||
|
|
||||||
|
registeredItems[itemName] = item
|
||||||
|
modItems[itemName] = item
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param shortModName string
|
||||||
|
---@return table<string, Item>?
|
||||||
|
function Smc.getRegisteredItemsByMod(shortModName)
|
||||||
|
return table.copy_with_metatables(registeredItemsByMod[shortModName])
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return table<string, Item>?
|
||||||
|
function Smc.getRegisteredItems()
|
||||||
|
return table.copy_with_metatables(registeredItems)
|
||||||
|
end
|
||||||
66
mods/SYSTEM/HelperLib/src/Lib/requires.lua
Normal 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
|
||||||
|
|
||||||
4
mods/UI/AdminListUI/init.lua
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
local modInfo = Mod.getInfo('smc__ui__admin_list')
|
||||||
|
local require = modInfo.require
|
||||||
|
|
||||||
|
return require('AdminListUI')
|
||||||
2
mods/UI/AdminListUI/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
name = smc__ui__admin_list
|
||||||
|
depends = smc__core__formspec
|
||||||
78
mods/UI/AdminListUI/src/AdminListUI.lua
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
local BaseUI, Formspec = Smc.requireBaseUI(), Smc.requireFormspec()
|
||||||
|
|
||||||
|
---@param self BaseUI
|
||||||
|
---@param playerName string
|
||||||
|
---@param isSelect boolean?
|
||||||
|
---@return string
|
||||||
|
local function getFormSpecString(self, playerName, isSelect)
|
||||||
|
if isSelect == nil and self:getContex(playerName, 'select_item') ~= nil then
|
||||||
|
isSelect = true
|
||||||
|
else
|
||||||
|
isSelect = false
|
||||||
|
end
|
||||||
|
|
||||||
|
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, false)
|
||||||
|
|
||||||
|
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
|
||||||
@@ -1,11 +1,4 @@
|
|||||||
local modInfo = Mod.getInfo('smc__core__formspec')
|
local BaseUI, Formspec = Smc.requireBaseUI(), Smc.requireFormspec()
|
||||||
local require = modInfo.require
|
|
||||||
|
|
||||||
---@type Formspec
|
|
||||||
local Formspec = require('Formspec')
|
|
||||||
|
|
||||||
---@type BaseUI
|
|
||||||
local BaseUI = Mod.getInfo('smc__core__base_ui').require('BaseUI')
|
|
||||||
|
|
||||||
---@param self BaseUI
|
---@param self BaseUI
|
||||||
---@param playerName string
|
---@param playerName string
|
||||||
|
|||||||