Jump to content

Recommended Posts

Hello ! I got an issue when making a new equipable item using the wand tutorial.

I make all idle anim and swap anim with spriter and compiled them with autocompiler

I'd make a new craft for this item but when i try to craft it i get "I can't do that"

In my server log i found a line with "Could not preload undefined prefab (myitem)"

 

The prefab is in the prefab list on modmain

 

What is wrong with my item ? my code is exaclty the same for the prefab file than the wand tutorial

Thank you for replying :) There is some informations :

 

Working directory treeview :

  • GlacialStaff
    • anim
      • glacialstaff.zip
      • swap_glacialstaff.zip
    • exported
      • glacialstaff
        • glacialstaff.png
        • glacialstaff.scml
        • glacialstaff.zip
        • grass-0.png
      • swap_glacialstaff
        • glacialstaff.png
        • swap_glacialstaff.scml
        • swap_glacialstaff.zip
    • images
      • tabimages
        • tab.tex
        • tab.xml
      • inventoryimages
        • glacialstaff.tex
        • glacialstaff.xml
    • prefabs
      • glacialstaff.lua
    • preview.png
    • modmain.lua
    • modinfo.lua
    • modicon.xml
    • modicon.tex

 

The modmain file :

local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local STRINGS    = GLOBAL.STRINGS
local TECH       = GLOBAL.TECH
local ACTIONS    = GLOBAL.ACTIONS

ACTIONS.CASTAOE.GLACIALSTAFF = "Call Ice Age"
STRINGS.NAMES.GLACIALSTAFF = "Glacial Staff"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.GLACIALSTAFF = "Frost power in my hands !"
STRINGS.RECIPE_DESC.GLACIALSTAFF   = "Glacial Staff"

PrefabsFiles = {
  "glacialstaff"
}

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

local mytab = AddRecipeTab("Tab test", 6, "images/tabimagestab.xml", "tab.tex", nil)

AddRecipe("glacialstaff"  , {Ingredient("bluegem", 1)}, mytab, TECH.SCIENCE_TWO, nil, nil, nil, nil, nil, "images/inventoryimages/glacialstaff.xml", "glacialstaff.tex")

And the glacialstaff.lua prefab

local assets= { 
  Asset("ANIM", "anim/glacialstaff.zip"),
  Asset("ANIM", "anim/swap_glacialstaff.zip"), 

  Asset("ATLAS", "images/inventoryimages/glacialstaff.xml"),
  Asset("IMAGE", "images/inventoryimages/glacialstaff.tex"),
}

local prefabs = {
}

local function fn(colour)
	local function OnEquip(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_object", "swap_glacialstaff", "glacialstaff")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
  end

  local function OnUnequip(inst, owner) 
    owner.AnimState:Hide("ARM_carry") 
    owner.AnimState:Show("ARM_normal") 
  end

  local inst = CreateEntity()
  local trans = inst.entity:AddTransform()
  local anim = inst.entity:AddAnimState()
  MakeInventoryPhysics(inst)

  anim:SetBank("glacialstaff")
  anim:SetBuild("glacialstaff")
  anim:PlayAnimation("idle")

  inst:AddComponent("inventoryitem")
  inst.components.inventoryitem.imagename = "glacialstaff"
  inst.components.inventoryitem.atlasname = "images/inventoryimages/glacialstaff.xml"

  inst:AddComponent("equippable")
  inst.components.equippable:SetOnEquip( OnEquip )
  inst.components.equippable:SetOnUnequip( OnUnequip )

  return inst
end

return  Prefab("common/inventory/glacialstaff", fn, assets, prefabs)

 

glacialstaff.zip

Edited by AireAyquaza
7 minutes ago, AireAyquaza said:

Do you have some tutorial to make swap anim for equipable item ? The wand tutorial tell to make "swap_myitem->BUILD" anim but this is not working on DST :/

 

owner.AnimState:OverrideSymbol("swap_object", "swap_glacialstaff", "symbol0")

 

3 minutes ago, AireAyquaza said:

What does "symbol0" mean exactly ?

in your .scml file(which you can open with a texteditor as well) you don't have a name for your folder tag

52f0f855-a476-454d-ae81-66c5030c8e12.png

so the autocompiler automatically names it "symbol" and the id

Edited by Aquaterion

Thank again for your help, i'm understanding better now. I still not understand how to correctly place the item in the character hand, in spriter there is a kind of circle i can move to set where the item is placed when i equip it, but this and the scale are not well rendered, i missed something again :/

See screenshots

spriter.png

spriter2.png

I believe the issue is that you're putting the pivot on the animation, but that animation is not actually used. What you have to do is open .scml in a texteditor again and copy the pivot_x and pivot_y from the animations to the image file

4fe9f88f-ecf9-4cb6-a3fc-47559e55d8a2.png

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