Jump to content

Recommended Posts

image.png.7e35e880ed4316b107a0189a57d81918.png

Used the template this

Hello everyone, I really need help, I'm trying to create a hat mod, the game does not display on the character, everything is fine on the floor and in the inventory. But it is on the head that it is not visible.

Everything worked until I renamed the custom item to glasses, and created the Scml file in a new way. It may be necessary to put sprites in other places in the spriter, but where?

 

19 hours ago, FerniFrenito said:

Could you show your code where you put the SetBank and the SetAnimation, in addition to the code where you declare the asset as ASSET("ATLAS", path) and so on?

modmain:

Spoiler

PrefabFiles = {
    "glasses",
}

-- Load in some assets globally
Assets = {
    Asset("ATLAS", "images/inventoryimages/glasses.xml"),
    Asset("IMAGE", "images/inventoryimages/glasses.tex"),
}

-- Load our item icon XMLs into the Minimap!
AddMinimapAtlas("images/inventoryimages/glasses.xml")

glasses:
 

Spoiler

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

local function OnEquip(inst, owner)
    -- This will override symbol "swap_body" of the equipping player with your custom build symbol.
    -- Here's what this function is overriding:
    -- owner.AnimState:OverrideSymbol(Player's_symbol, Your_build(*.zip_filename), Symbol_from_your_build(name_of_subfolder_with_art)
    owner.AnimState:OverrideSymbol("swap_glasses", "glasses", "swap_glasses")
    
    -- Show/Hide some of the layers of the character while equipping the hat.
    owner.AnimState:Show("HAT")
    owner.AnimState:Show("HAIR_HAT")
    owner.AnimState:Hide("HAIR_NOHAT")
    owner.AnimState:Hide("HAIR")
    
    -- If the equipping guy is the player, do some additional stuff.
    if owner:HasTag("player") then
        owner.AnimState:Hide("HEAD")
        owner.AnimState:Show("HEAD_HAT")
    end
    
 

local function OnUnequip(inst, owner) 
    -- Clear the hat symbol from wearer's head.
    owner.AnimState:ClearOverrideSymbol("swap_glasses")
    
    -- Show/Hide some of the layers of the character while unequipping the hat.
    owner.AnimState:Hide("HAT")
    owner.AnimState:Hide("HAIR_HAT")
    owner.AnimState:Show("HAIR_NOHAT")
    owner.AnimState:Show("HAIR")

    -- If the unequipping guy is the player, do some additional stuff.
    if owner:HasTag("player") then
        owner.AnimState:Show("HEAD")
        owner.AnimState:Hide("HEAD_HAT")
    end
    
    -- Stop consuming usage percent if the hat is not equipped.
    if inst.components.fueled ~= nil then
        inst.components.fueled:StopConsuming()
    end
end

--[[ ANIMSTATE ]]--
    -- This is the name visible on the top of hierarchy in Spriter.
    inst.AnimState:SetBank("glasses")
    -- This is the name of your compiled*.zip file.
    inst.AnimState:SetBuild("glasses")
    -- This is the animation name while item is on the ground.
    inst.AnimState:PlayAnimation("anim")




 

I hope this is what I should have send. I've been trying to fix it for days

19 hours ago, FerniFrenito said:

Could you show your code where you put the SetBank and the SetAnimation, in addition to the code where you declare the asset as ASSET("ATLAS", path) and so on?

 

Ok i see the problem. 

local function OnEquip(inst, owner)
    -- This will override symbol "swap_body" of the equipping player with your custom build symbol.
    -- Here's what this function is overriding:
    -- owner.AnimState:OverrideSymbol(Player's_symbol, Your_build(*.zip_filename), Symbol_from_your_build(name_of_subfolder_with_art)
    owner.AnimState:OverrideSymbol("swap_glasses", "glasses", "swap_glasses") -- <-- HERE IS THE PROBLEM
    
    -- Show/Hide some of the layers of the character while equipping the hat.
    owner.AnimState:Show("HAT")
    owner.AnimState:Show("HAIR_HAT")

because you are trying override "swap_glasses" but that doesn't exist, you need to override "swap_hat". The other parameters are correct,, but i will explain each of them:

OverrideSymbol(var1, var2, var3)

var1 : the original "animation" which you want to override. In this case "swap_hat".

var2 : the name of your .zip file that contains your swap animation. In fact, the bank (an entity in Spriter) can have any name.

var3 : the name of the folder that contains your animation sprites, normally is named "swap_hat" but if you named it differently, you need to put that name here.

Now, in the unequip function, you need to clear the override with the original name of the "animation" (in this case "swap_hat"):

owner.AnimState:ClearOverrideSymbol("swap_hat")

And that is all.

46 minutes ago, FerniFrenito said:

Хорошо, я вижу проблему. 

local function OnEquip(inst, owner)
    -- This will override symbol "swap_body" of the equipping player with your custom build symbol.
    -- Here's what this function is overriding:
    -- owner.AnimState:OverrideSymbol(Player's_symbol, Your_build(*.zip_filename), Symbol_from_your_build(name_of_subfolder_with_art)
    owner.AnimState:OverrideSymbol("swap_glasses", "glasses", "swap_glasses") -- <-- HERE IS THE PROBLEM
    
    -- Show/Hide some of the layers of the character while equipping the hat.
    owner.AnimState:Show("HAT")
    owner.AnimState:Show("HAIR_HAT")

Поскольку вы пытаетесь переопределить "swap_glasses", но его не существует, вам нужно переопределить "swap_hat". Остальные параметры верны, но я объясню каждый из них:

OverrideSymbol(var1, var2, var3)

var1 : исходная "анимация", которую вы хотите переопределить. В данном случае "swap_hat".

var2 : имя файла .zip, содержащего анимацию подкачки. На самом деле, банк (юридическое лицо в Spriter) может иметь любое название.

var3 : имя папки, содержащей ваши анимационные спрайты, обычно называется "swap_hat", но если вы назвали ее по-другому, вам нужно указать это имя здесь.

Теперь в функции unequip нужно очистить переопределение с оригинальным именем "анимации" (в данном случае "swap_hat"):

owner.AnimState:ClearOverrideSymbol("swap_hat")

И это все.

 owner.AnimState:OverrideSymbol("swap_glasses", "glasses", "swap_glasses")

so what should this line look like?

local function OnEquip(inst, owner)
    -- This will override symbol "swap_body" of the equipping player with your custom build symbol.
    -- Here's what this function is overriding:
    -- owner.AnimState:OverrideSymbol(Player's_symbol, Your_build(*.zip_filename), Symbol_from_your_build(name_of_subfolder_with_art)
    owner.AnimState:OverrideSymbol("swap_hat", "glasses", "swap_glasses")
    
local function OnUnequip(inst, owner) 
    -- Clear the hat symbol from wearer's head.
    owner.AnimState:ClearOverrideSymbol("swap_hat")
    

 

its right?

Edited by Famyliyan
5 minutes ago, FerniFrenito said:

Yes

I've checked if I'm leaving ("swap_glasses", "glasses", "swap_glasses") Then the hat is invisible
but if I do this:  owner.AnimState:OverrideSymbol("swap_hat", "glasses", "swap_glasses")
It's visible, but with an error. Here it is:image.png.e20d18bb030423a6083c75166da3d138.pngimage.png.d1861c0cc8edacbc8b1428742b345d81.png

2 minutes ago, Famyliyan said:

I've checked if I'm leaving ("swap_glasses", "glasses", "swap_glasses") Then the hat is invisible
but if I do this:  owner.AnimState:OverrideSymbol("swap_hat", "glasses", "swap_glasses")
It's visible, but with an error. Here it is:image.png.e20d18bb030423a6083c75166da3d138.pngimage.png.d1861c0cc8edacbc8b1428742b345d81.png

The first reason is because your hat doesn't need to hide the hair, you need to remove the AnimState:Hide("head") or something like that. The second problem is with the animations.

image.png.5b3267da3f765f41b1012442db9e1a10.png

Please, look at the up-left corner. For some reason, your sprite name needs to end with "_3_0". Try that and say me if work

______________________________

Доброе утро, или, может быть, ночь, приятель.

3 minutes ago, FerniFrenito said:

AnimState:Hide("head")

sorry for many questions..what needs to be removed from this

if owner:HasTag("player") then
        owner.AnimState:Hide("HEAD")
        owner.AnimState:Show("HEAD_HAT")
    end

-- Show/Hide some of the layers of the character while unequipping the hat.
    owner.AnimState:Hide("HAT")
    owner.AnimState:Hide("HAIR_HAT")
    owner.AnimState:Show("HAIR_NOHAT")
    owner.AnimState:Show("HAIR")

    -- If the unequipping guy is the player, do some additional stuff.
    if owner:HasTag("player") then
        owner.AnimState:Show("HEAD")
        owner.AnimState:Hide("HEAD_HAT")

1 minute ago, Famyliyan said:

sorry for many questions..what needs to be removed from this

if owner:HasTag("player") then
        owner.AnimState:Hide("HEAD")
        owner.AnimState:Show("HEAD_HAT")
    end

-- Show/Hide some of the layers of the character while unequipping the hat.
    owner.AnimState:Hide("HAT")
    owner.AnimState:Hide("HAIR_HAT")
    owner.AnimState:Show("HAIR_NOHAT")
    owner.AnimState:Show("HAIR")

    -- If the unequipping guy is the player, do some additional stuff.
    if owner:HasTag("player") then
        owner.AnimState:Show("HEAD")
        owner.AnimState:Hide("HEAD_HAT")

This, because you don't need to hide "head" and you don't need to show "head_hat" since your hat doesn't cover the hair

owner.AnimState:Hide("HEAD")
owner.AnimState:Show("HEAD_HAT")
  • Like 1
27 minutes ago, FerniFrenito said:

The first reason is because your hat doesn't need to hide the hair, you need to remove the AnimState:Hide("head") or something like that. The second problem is with the animations.

image.png.5b3267da3f765f41b1012442db9e1a10.png

Please, look at the up-left corner. For some reason, your sprite name needs to end with "_3_0". Try that and say me if work

______________________________

Доброе утро, или, может быть, ночь, приятель.

that is, i need to add 3_0 in each of the swap_glasses?image.png.fbecc0fc0c022045d75f2b4322424c20.png

14 minutes ago, FerniFrenito said:

No, only in the layer name. Do a double-click on the object in the corner (which i signed in the previous answer)

image.png.13316bd7d314f3bd1ca9892457c9f7cb.pngimage.png.e34a844ac07360688e3090200afeef5b.png
sorry, I don't really understand which layer it is
That's how I did it.

image.png.4eb1f86b7f66e718f4fcbb18aedbaff7.png

image.png

Edited by Famyliyan
4 minutes ago, Famyliyan said:

image.png.13316bd7d314f3bd1ca9892457c9f7cb.png

What's happening is that you're using a template, and I don't know how it works. Maybe if you change z-order of the swap_glasses 0 and swap_glasses 1,  I mean, try putting swap_glasses 2 first in the z order, swap_glasses 1 next and swap_glasses 0 last.

I tried all the templates, but I couldn't get it right. I just didn't know what to insert where.

 

 

6 minutes ago, FerniFrenito said:

What's happening is that you're using a template, and I don't know how it works. Maybe if you change z-order of the swap_glasses 0 and swap_glasses 1,  I mean, try putting swap_glasses 2 first in the z order, swap_glasses 1 next and swap_glasses 0 last.

image.png.3480e7de8bad8d0edc10db2ba0ca4886.pngimage.png.6920f6cb97fcdc0c606c900bdbfffb15.png

4 minutes ago, Famyliyan said:

I tried all the templates, but I couldn't get it right. I just didn't know what to insert where.

 

 

image.png.3480e7de8bad8d0edc10db2ba0ca4886.pngimage.png.6920f6cb97fcdc0c606c900bdbfffb15.png

Yeah thats works. Now:

image.png.f6e6b24306a6e2fdabc010b3ea941b2e.png

Do you see that gray point? move it on your sprite. It represents the "center" of your sprite (although it's not obligatory to place in the literal center) after that, right-click and click in "override the center" of something like that, i think it's the second option.

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...