HelperLib: add require methods
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
---@type TileSheet
|
local Item, TileSheet = Smc.requireItem(), Smc.requireTileSheet()
|
||||||
local TileSheet = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
|
|
||||||
|
|
||||||
---@type Item
|
|
||||||
local Item = Mod.getInfo('smc__core__item').require('Item')
|
|
||||||
|
|
||||||
---@type Item.ItemDefinition
|
---@type Item.ItemDefinition
|
||||||
local defaultEssenceDef = {
|
local defaultEssenceDef = {
|
||||||
@@ -15,7 +11,6 @@ local defaultEssenceDef = {
|
|||||||
|
|
||||||
local defaultEssence = Item:getExtended(defaultEssenceDef)
|
local defaultEssence = Item:getExtended(defaultEssenceDef)
|
||||||
|
|
||||||
---@type TileSheet
|
|
||||||
local ts = TileSheet:new('essences_sheet.png', 16, 16)
|
local ts = TileSheet:new('essences_sheet.png', 16, 16)
|
||||||
|
|
||||||
defaultEssence:new({
|
defaultEssence:new({
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
---@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 defaultLogDef = {
|
local defaultLogDef = {
|
||||||
|
|||||||
@@ -8,3 +8,4 @@ require('Lib.color')
|
|||||||
require('Lib.immersiveCraftData')
|
require('Lib.immersiveCraftData')
|
||||||
require('Lib.getObjectByGUID')
|
require('Lib.getObjectByGUID')
|
||||||
require('Lib.receiveFields')
|
require('Lib.receiveFields')
|
||||||
|
require('Lib.requires')
|
||||||
41
mods/SYSTEM/HelperLib/src/Lib/requires.lua
Normal file
41
mods/SYSTEM/HelperLib/src/Lib/requires.lua
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
-- Global methods for require classes.
|
||||||
|
|
||||||
|
---@return Item
|
||||||
|
function Smc.requireItem()
|
||||||
|
---@type Item
|
||||||
|
local class = Mod.getInfo('smc__core__item').require('Item')
|
||||||
|
|
||||||
|
return class
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return Node
|
||||||
|
function Smc.requireNode()
|
||||||
|
---@type Node
|
||||||
|
local class = Mod.getInfo('smc__core__node').require('Node')
|
||||||
|
|
||||||
|
return class
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return Plant
|
||||||
|
function Smc.requirePlant()
|
||||||
|
---@type Plant
|
||||||
|
local class = Mod.getInfo('smc__core__plant').require('Plant')
|
||||||
|
|
||||||
|
return class
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return ItemFactory
|
||||||
|
function Smc.requireItemFactory()
|
||||||
|
---@type ItemFactory
|
||||||
|
local class = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
|
||||||
|
|
||||||
|
return class
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return TileSheet
|
||||||
|
function Smc.requireTileSheet()
|
||||||
|
---@type TileSheet
|
||||||
|
local class = Mod.getInfo('smc__core__tilesheet').require('TileSheet')
|
||||||
|
|
||||||
|
return class
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user