Jump to content

Recommended Posts

I'm making a mod called blue chest, it's some sort of an "ice chest".  I have been working on this for a few days, stuck with this very problem. Hope someone could help me figure out how to make it work. Big thanks !! The attached file is my blue chest mod.

This is the overview of my mod:

/blue_chest
├── anim
│   ├── blue_chest.zip
│   └── ui_chest_3x3.zip
├── images
│   ├── inventoryimages
│   │   ├── blue_chest.tex    --- here is the blue chest icon, it's right there, but why the game could not find it ?
│   │   └── blue_chest.xml
│   └── pngs
│       ├── blue_chest.png
│       └── blue_chest_icon.png
├── modicon.tex
├── modicon.xml
├── modinfo.lua
├── modmain.lua
├── preview.png
└── scripts
    └── prefabs
        └── blue_chest.lua

The problem is I can't get the craft tab icon for my blue chest to work properly, the game supposed to load images/inventoryimages/blue_chest.tex file as icon for blue chest, but what I see is another image, and more interesting, it always replaces blue chest icon with the icon of the last item in the previous tab I just opened.

First it was replaced with the last item in structure tab

20210619222905_1.thumb.jpg.838bf3d386b2106419563b7b8675078b.jpg

then I opened food tab, it shows up like this, the icon becomes the last item in the food tab

20210619222917_1.thumb.jpg.eb258caab17c9767a6c82dfffd95e40f.jpg

 

blue_chest.xml has one line of code:

<Atlas><Texture filename="blue_chest.tex" /><Elements><Element name="blue_chest.tex" u1="0" u2="1" v1="0" v2="1" /></Elements></Atlas>

 

This is the code in modmail.lua:

GLOBAL.setmetatable(
    env,
    {
        __index = function(t, k)
            return GLOBAL.rawget(GLOBAL, k)
        end
    }
)

PrefabFiles = {
    "blue_chest",
}

Assets = {
    Asset("ATLAS", "images/inventoryimages/blue_chest.xml"),
    Asset("IMAGE", "images/inventoryimages/blue_chest.tex"),
    Asset("ANIM", "anim/blue_chest.zip"),
    Asset("ANIM", "anim/ui_chest_3x3.zip"),
}

local containers = require "containers"

local params = {}

params.blue_chest = {
    widget = {
        slotpos = {},
        animbank = "ui_chest_3x3",
        animbuild = "ui_chest_3x3",
        pos = GLOBAL.Vector3(0, 200, 0),
        side_align_tip = 160
    },
    type = "blue_chest"
}

for y = 2, 0, -1 do
    for x = 0, 2 do
        table.insert(params.blue_chest.widget.slotpos, Vector3(80 * x - 80 * 2 + 80, 80 * y - 80 * 2 + 80, 0))
    end
end

local containers_widgetsetup_base = containers.widgetsetup
function containers.widgetsetup(container, prefab, data, ...)
    local t = params[prefab or container.inst.prefab]
    if t ~= nil then
        for k, v in pairs(t) do
            container[k] = v
        end
        container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0)
    else
        containers_widgetsetup_base(container, prefab, data, ...)
    end
end

for k, v in pairs(params) do
    containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, v.widget.slotpos ~= nil and #v.widget.slotpos or 0)
end

AddRecipe(
    "blue_chest",
    {Ingredient("cutstone", 2), Ingredient("bluegem", 4), Ingredient("thulecite", 4)},
    RECIPETABS.TOWN,
    TECH.SCIENCE_TWO,
    "blue_chest_placer",
    1, nil, nil, nil, "images/inventoryimages/blue_chest.xml", "images/inventoryimages/blue_chest.tex"
)

STRINGS.NAMES.BLUE_CHEST = "Blue Chest"
STRINGS.RECIPE_DESC.BLUE_CHEST = "A chest with magic"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.BLUE_CHEST = "The Power Of Youth!"

 

 

And I get some logs from client_log.txt, but no idea how to fix this:

[00:02:24]: WARNING! Could not find region 'images/inventoryimages/blue_chest.tex' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'. Is the region specified in the atlas?
[00:02:24]: Looking for default texture '' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: Error Looking for default texture in from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: WARNING! Could not find region 'images/inventoryimages/blue_chest.tex' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'. Is the region specified in the atlas?
[00:02:24]: Looking for default texture '' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: Error Looking for default texture in from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: WARNING! Could not find region 'images/inventoryimages/blue_chest.tex' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'. Is the region specified in the atlas?
[00:02:24]: Looking for default texture '' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: Error Looking for default texture in from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: WARNING! Could not find region 'images/inventoryimages/blue_chest.tex' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'. Is the region specified in the atlas?
[00:02:24]: Looking for default texture '' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: Error Looking for default texture in from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: WARNING! Could not find region 'images/inventoryimages/blue_chest.tex' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'. Is the region specified in the atlas?
[00:02:24]: Looking for default texture '' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: Error Looking for default texture in from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: WARNING! Could not find region 'images/inventoryimages/blue_chest.tex' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'. Is the region specified in the atlas?
[00:02:24]: Looking for default texture '' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: Error Looking for default texture in from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: WARNING! Could not find region 'images/inventoryimages/blue_chest.tex' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'. Is the region specified in the atlas?
[00:02:24]: Looking for default texture '' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:24]: Error Looking for default texture in from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:39]: WARNING! Could not find region 'images/inventoryimages/blue_chest.tex' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'. Is the region specified in the atlas?
[00:02:39]: Looking for default texture '' from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.
[00:02:39]: Error Looking for default texture in from atlas '../mods/workshop-2495791144/images/inventoryimages/blue_chest.xml'.

 

Thanks again !!!!!

blue_chest.zip

Edited by asingingbird

Try changing 

AddRecipe(
    "blue_chest",
    {Ingredient("cutstone", 2), Ingredient("bluegem", 4), Ingredient("thulecite", 4)},
    RECIPETABS.TOWN,
    TECH.SCIENCE_TWO,
    "blue_chest_placer",
    1, nil, nil, nil, "images/inventoryimages/blue_chest.xml", "images/inventoryimages/blue_chest.tex"
)

to 

AddRecipe(
    "blue_chest",
    {Ingredient("cutstone", 2), Ingredient("bluegem", 4), Ingredient("thulecite", 4)},
    RECIPETABS.TOWN,
    TECH.SCIENCE_TWO,
    "blue_chest_placer",
    1, nil, nil, nil, "images/inventoryimages/blue_chest.xml", "blue_chest.tex"
)

When you enter the tex file, it is already looking for it in xml, so you won't need the other folders, you only need to enter the name of the tex. If your tex file is named the same as your xml file, you won't even need to set the tex file, you can just leave it empty and it will work.

  • Like 1
7 hours ago, Monti18 said:

Try changing 


AddRecipe(
    "blue_chest",
    {Ingredient("cutstone", 2), Ingredient("bluegem", 4), Ingredient("thulecite", 4)},
    RECIPETABS.TOWN,
    TECH.SCIENCE_TWO,
    "blue_chest_placer",
    1, nil, nil, nil, "images/inventoryimages/blue_chest.xml", "images/inventoryimages/blue_chest.tex"
)

to 


AddRecipe(
    "blue_chest",
    {Ingredient("cutstone", 2), Ingredient("bluegem", 4), Ingredient("thulecite", 4)},
    RECIPETABS.TOWN,
    TECH.SCIENCE_TWO,
    "blue_chest_placer",
    1, nil, nil, nil, "images/inventoryimages/blue_chest.xml", "blue_chest.tex"
)

When you enter the tex file, it is already looking for it in xml, so you won't need the other folders, you only need to enter the name of the tex. If your tex file is named the same as your xml file, you won't even need to set the tex file, you can just leave it empty and it will work.

You are amazing !! It did work, thanks a lot.

The solution is

AddRecipe(
	"blue_chest",
	{Ingredient("cutstone", 2), Ingredient("bluegem", 4), Ingredient("thulecite", 4)},
	RECIPETABS.TOWN,
	TECH.SCIENCE_TWO,
	"blue_chest_placer",
	1, nil, nil, nil, "images/inventoryimages/blue_chest.xml"
)

20210620092753_1.thumb.jpg.11b081151195192d3f0ab6177e878b9f.jpg

Edited by asingingbird

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...