Add new admin command /create_locale

This commit is contained in:
Van
2026-07-23 18:59:39 +03:00
parent be2d28fc90
commit 6935673be7
2 changed files with 78 additions and 8 deletions

View File

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