Jump to content

Help with modding in item.


Recommended Posts

So whenever I craft the item myself as the host everything works fine. But when someone is playing with me they don't see the item on the ground and when they have it themselves and equip it, it shows them having it equipped ingame but in their hotbar nothing is there. Is it a problem with my anim files or the coding of the item? Your help is appreciated.

 

modmain.lua

yorhablade.lua

Spoiler

PrefabFiles = {
    "a2",
    "a2_none",
    "yorhablade",
}

Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/a2.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/a2.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/a2.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/a2.xml" ),
    
    Asset( "IMAGE", "images/selectscreen_portraits/a2_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/a2_silho.xml" ),

    Asset( "IMAGE", "bigportraits/a2.tex" ),
    Asset( "ATLAS", "bigportraits/a2.xml" ),
    
    Asset( "IMAGE", "images/map_icons/a2.tex" ),
    Asset( "ATLAS", "images/map_icons/a2.xml" ),
    
    Asset( "IMAGE", "images/avatars/avatar_a2.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_a2.xml" ),
    
    Asset( "IMAGE", "images/avatars/avatar_ghost_a2.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_ghost_a2.xml" ),
    
    Asset( "IMAGE", "images/avatars/self_inspect_a2.tex" ),
    Asset( "ATLAS", "images/avatars/self_inspect_a2.xml" ),
    
    Asset( "IMAGE", "images/names_a2.tex" ),
    Asset( "ATLAS", "images/names_a2.xml" ),
    
    Asset( "IMAGE", "images/names_gold_a2.tex" ),
    Asset( "ATLAS", "images/names_gold_a2.xml" ),
    
    Asset( "IMAGE", "bigportraits/a2_none.tex" ),
    Asset( "ATLAS", "bigportraits/a2_none.xml" ),
    
    Asset("ANIM", "anim/yorhablade.zip"),
    Asset("ANIM", "anim/swap_yorhablade.zip"),
    Asset("ATLAS", "images/inventoryimages/yorhablade.xml"),    
    Asset("IMAGE", "images/inventoryimages/yorhablade.tex"),

}

AddMinimapAtlas("images/map_icons/a2.xml")

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS

local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local TECH = GLOBAL.TECH

STRINGS.NAMES.YORHABLADE = "Yorhablade"
STRINGS.RECIPE_DESC.YORHABLADE = "A blade given to YoRHa Units"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.YORHABLADE = "It seems to have been overgrown with lunar tears..."


-- The character select screen lines
STRINGS.CHARACTER_TITLES.a2 = "Attacker No.2"
STRINGS.CHARACTER_NAMES.a2 = "Esc"
STRINGS.CHARACTER_DESCRIPTIONS.a2 = "*Well versed in combat\n*Faster than most\n*A Prototype"
STRINGS.CHARACTER_QUOTES.a2 = "\"Command is the one that betrayed you...\""

-- Custom speech strings
STRINGS.CHARACTERS.A2 = require "speech_a2"

-- The character's name as appears in-game 
STRINGS.NAMES.A2 = "A2"

-- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL.
AddModCharacter("a2", "FEMALE")


 

Spoiler

local assets=

    Asset("ANIM", "anim/yorhablade.zip"),
    Asset("ANIM", "anim/swap_yorhablade.zip"), 

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

local prefabs = 
{
}

local function fn(colour)

    local function OnEquip(inst, owner) 
        --owner.AnimState:OverrideSymbol("swap_object", "swap_yorhablades", "purplestaff")
        owner.AnimState:OverrideSymbol("swap_object", "swap_yorhablade", "yorhablade")
        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("yorhablade")
    anim:SetBuild("yorhablade")
    anim:PlayAnimation("idle")
    
    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(60)
    
    inst:AddComponent("finiteuses")   
    inst.components.finiteuses:SetMaxUses(150)    
    inst.components.finiteuses:SetUses(150)
    inst.components.finiteuses:SetOnFinished(inst.Remove)
    
    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "yorhablade"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/yorhablade.xml"
    
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )

    return inst
end

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

 

Link to comment
Share on other sites

Your weapon is set up for DS, not for DST. It has no networking, and the components etc. should not be added on the clients.

Check out my newcomer post. Not only does it have a lot of great info about getting into coding, modding and debugging for DS/DST, it also has the Cactus Armor mod as a zip, which is the simplest possible equippable item mod for DST. You can see exactly which things your mod is missing, and where, by comparing its prefab file to your prefab file. The important parts are the AddNetwork() and SetPristine() calls and which things come before and after the TheWorld.ismastersim check.

Link to comment
Share on other sites

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
 Share

×
  • Create New...