Jump to content

Recommended Posts

I need help moding a fishing rod so, that it has infinite durability. Can someone fix my fishinrod.lua?

 

local assets =
{
    Asset("ANIM", "anim/fishinrod.zip"),
    Asset("ANIM", "anim/swap_fishinrod.zip"),
 
 Asset("ATLAS", "images/inventoryimages/fishinrod.xml"),
    Asset("IMAGE", "images/inventoryimages/fishinrod.tex"),
}
local prefabs =
{
 "test"
}
local function fn(colour)
 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
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.components.inventoryitem.atlasname = "images/inventoryimages/fishinrod.xml" 
    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)
Link to comment
https://forums.kleientertainment.com/forums/topic/87312-fishing-rod-mod/
Share on other sites

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

local function onequip (inst, owner)
	owner.AnimState:OverrideSymbol("swap_object", "swap_fishingrod", "swap_fishingrod")--owner.AnimState:OverrideSymbol("swap_object", "swap_fishinrod", "swap_fishinrod")
	owner.AnimState:OverrideSymbol("fishingline", "swap_fishingrod", "fishingline")--owner.AnimState:OverrideSymbol("fishingline", "swap_fishinrod", "fishingline")
	owner.AnimState:OverrideSymbol("FX_fishing", "swap_fishingrod", "FX_fishing")--owner.AnimState:OverrideSymbol("FX_fishing", "swap_fishinrod", "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:SetBank("fishinrod")
    inst.AnimState:SetBuild("fishingrod")--inst.AnimState:SetBuild("fishinrod")
    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.components.inventoryitem.atlasname = "images/inventoryimages/fishinrod.xml" 
    -------
    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) 

Didnt really test or anything but I fixed the things I noticed that were wrong.

I left comments of certain things I wasn't sure you wanted to change

3 hours ago, Aquaterion said:

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

local function onequip (inst, owner)
	owner.AnimState:OverrideSymbol("swap_object", "swap_fishingrod", "swap_fishingrod")--owner.AnimState:OverrideSymbol("swap_object", "swap_fishinrod", "swap_fishinrod")
	owner.AnimState:OverrideSymbol("fishingline", "swap_fishingrod", "fishingline")--owner.AnimState:OverrideSymbol("fishingline", "swap_fishinrod", "fishingline")
	owner.AnimState:OverrideSymbol("FX_fishing", "swap_fishingrod", "FX_fishing")--owner.AnimState:OverrideSymbol("FX_fishing", "swap_fishinrod", "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:SetBank("fishinrod")
    inst.AnimState:SetBuild("fishingrod")--inst.AnimState:SetBuild("fishinrod")
    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.components.inventoryitem.atlasname = "images/inventoryimages/fishinrod.xml" 
    -------
    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) 

Didnt really test or anything but I fixed the things I noticed that were wrong.

I left comments of certain things I wasn't sure you wanted to change

it crashes :(

21 minutes ago, Aquaterion said:

well providing a crash log would be ideal..

DST.exe stops running and doesn't give any crash log. I've tried to find the problem in client_log and found the following:

00:01:10]: ..\source\animlib\animmanager.cpp(517) :: Tried to add build [fishingrod] from file [../mods/Test(3)/anim/fishinrod.zip] but we've already added a build with that name!

could that be the source of the problem?

 

31 minutes ago, Ray025 said:

it will just be a normal fishing rod with no durability

then you probably don't need to have custom assets, just use the existing fishingrod's assets

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:AddTag("fishingrod")
	
    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 = "fishingrod"
    --inst.components.inventoryitem.atlasname = "images/inventoryimages/fishingrod.xml" 
    -------
    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) 

 

25 minutes ago, Aquaterion said:

then you probably don't need to have custom assets, just use the existing fishingrod's assets


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:AddTag("fishingrod")
	
    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 = "fishingrod"
    --inst.components.inventoryitem.atlasname = "images/inventoryimages/fishingrod.xml" 
    -------
    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) 

 

so I should make a (whatever the name).lua with the code you sent me, and then put it in my character's start_inv. Did i miss the point?

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