Jump to content

Recommended Posts

So i've been messing with other mods files, and have been able to make custom icons/names for items and have them with their own animation (sorta) But i copied the .lua files from dst for the fishing rod.. but i can't seem to ever give it a actual inventory image or name, what am i doing wrong? Or better yet, should i start making a fishing rod fro mscratch?

Link to comment
https://forums.kleientertainment.com/forums/topic/71363-custom-fishing-rod/
Share on other sites

local assets =
{
    Asset("ANIM", "anim/fishingrod.zip"),
    Asset("ANIM", "anim/swap_fishingrod.zip"),
}

local function onequip (inst, owner)
    owner.AnimState:OverrideSymbol("swap_object", "swap_fishingrod", "swap_fishingrod")
    owner.AnimState:OverrideSymbol("fishingline", "swap_fishingrod", "fishingline")
    owner.AnimState:OverrideSymbol("FX_fishing", "swap_fishingrod", "FX_fishing")
    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")
    owner.AnimState:ClearOverrideSymbol("fishingline")
    owner.AnimState:ClearOverrideSymbol("FX_fishing")
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("fishingrod")
    inst.AnimState:SetBuild("fishingrod")
    inst.AnimState:PlayAnimation("idle")

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.FISHINGROD_DAMAGE)
    inst.components.weapon.attackwear = 4
    -----
    inst:AddComponent("fishingrod")
    inst.components.fishingrod:SetWaitTimes(4, 40)
    inst.components.fishingrod:SetStrainTimes(0, 5)
    -------
    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "fishinrod"

    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)

    MakeHauntableLaunch(inst)

    return inst
end

return Prefab("common/inventory/fishinrod", fn, assets)

 

The reason it doesn't have a ingame inventory to show is because the game does not provide one.

Edited by Lokoluna


    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "fishinrod" 

Try adding a line :

	inst.components.inventoryitem.atlasname = "images/inventoryimages/fishinrod.xml"

(or whatever is your xml name)

Also, you probably need this in the modmain.lua

 



        Assets = 
        {	
			Asset("ATLAS", "images/inventoryimages/fishinrod.xml"),
			
        }
		

Let me know if it work. If not, put the entire mod please :) It's not easy to know if the error is in one file or another.

 

54 minutes ago, Lokoluna said:

Worked Great thank you. Do you know how to add a way to make an item be able to be burned?

A good file to study up on is the standardcomponents.lua file in the data/scripts folder. It has a lot of useful global functions that a lot of the standard prefabs use.

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