Jump to content

Strange error message with new custom item prefab


Recommended Posts

I'm not entirely sure what the problem with this code is. I'm new to modding and trying to make a very simple custom weapon. I've attached a screenshot of the error message and the lua text. Any help at all would be greatly appreciated. Thank you! :)

Quote

local assets=
{
    Asset("ANIM", "anim/talon.zip"),
    Asset("ANIM", "anim/swap_talon.zip"),

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

local prefabs = {}local function fn()
    local function OnEquip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_object", "swap_talon", "swap_talon")
    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()
    local sound = inst.entity:AddSoundEmitter()
    MakeInventoryPhysics(inst)
    anim:SetBank("talon")
    anim:SetBuild("talon")
    anim:PlayAnimation("idle")
    inst:AddComponent("inspectable")
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "talon"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/talon.xml"
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )
    return instendreturn
    Prefab("common/inventory/talon", fn, assets, prefabs)

 

dontstarve_steam_FOBGCl7rRa.png

Link to comment
Share on other sites

Looks like you forgot to end the function, on the second line of the error it says "'end' expected (to close 'function' on line 10) near 'Prefab'" which means that the function that started on line 10 was supposed to have "end" somewhere near line 35.

Try this:

local assets=
{
    Asset("ANIM", "anim/talon.zip"),
    Asset("ANIM", "anim/swap_talon.zip"),

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

local prefabs = {}local function fn()
    local function OnEquip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_object", "swap_talon", "swap_talon")
    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()
    local sound = inst.entity:AddSoundEmitter()
    MakeInventoryPhysics(inst)
    anim:SetBank("talon")
    anim:SetBuild("talon")
    anim:PlayAnimation("idle")
    inst:AddComponent("inspectable")
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "talon"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/talon.xml"
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )
    return instendreturn
    Prefab("common/inventory/talon", fn, assets, prefabs)
end                                                --  <------Add end right here to close the function that was started on line 10

I am still somewhat new to coding but I have spent quite a bit of time working on a mod and feel confident that this will fix your problem.

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