Jump to content

Need some help


Recommended Posts

Heya! I need some help. I've got item that, while eqquiped, must change player's voice. But I've got two problems for now:

  1. While my item is eqquiped, player's voice disappears.
  2. Game crasghes if I unequip item with
248: variable 'owner' is not declared

If someone'll help me, I'll give en reward! :) 

myprefab.lua is here:

http://pastebin.com/1NhRVUF1

Edited by makar5000
  • Like 1
Link to comment
Share on other sites

I'm not sure about your voice problem, but as for the crash, try adding the following in your OnUnequip function (before the "owner.soundsname = (player)" line):

local owner = inst.components.inventoryitem.owner

... or something similar. The error you're getting seems to be because you never told the 'OnUnequip' function what "owner" means (it can't take the meaning from OnEquipWils, as that is a different function and it's a local variable). Hope this helps.

Link to comment
Share on other sites

local function  OnEquipWils(inst, builder)
 
    local spawn_fx = SpawnPrefab("spawn_fx_medium")
    spawn_fx.Transform:SetPosition(inst.Transform:GetWorldPosition() )
   
    SetSkinMode(builder.AnimState, "wilson", "wilson", builder.components.skinner:GetClothing(), nil, "wilson")
    --inst.soundsname = "wilson"
   
        local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
        if owner then
            local sanity = owner.components.sanity
            if sanity then
                sanity:DoDelta(-10,false)
            end
        end
       
    --owner.talker_path_override = "dontstarve_DLC001/characters/"
    builder.soundsname = "wilson"
end
 
local function OnUnequip(inst, builder)
 
    local spawn_fx = SpawnPrefab("spawn_fx_medium")
    spawn_fx.Transform:SetPosition(inst.Transform:GetWorldPosition() )
   
    --Возвращаем прежнюю анимацию! (Спасибо DarkKingBoo с форума.)
    local player = builder.prefab
    builder.AnimState:SetBank("wilson")
    builder.AnimState:SetBuild(player)
   
    builder.soundsname = (player)
end

@makar5000  "builder" = "owner". So where is my reward :D.

Link to comment
Share on other sites

Just now, zUsername said:

local function  OnEquipWils(inst, builder)
 
    local spawn_fx = SpawnPrefab("spawn_fx_medium")
    spawn_fx.Transform:SetPosition(inst.Transform:GetWorldPosition() )
   
    SetSkinMode(builder.AnimState, "wilson", "wilson", builder.components.skinner:GetClothing(), nil, "wilson")
    --inst.soundsname = "wilson"
   
        local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
        if owner then
            local sanity = owner.components.sanity
            if sanity then
                sanity:DoDelta(-10,false)
            end
        end
       
    --owner.talker_path_override = "dontstarve_DLC001/characters/"
    builder.soundsname = "wilson"
end
 
local function OnUnequip(inst, builder)
 
    local spawn_fx = SpawnPrefab("spawn_fx_medium")
    spawn_fx.Transform:SetPosition(inst.Transform:GetWorldPosition() )
   
    --Возвращаем прежнюю анимацию! (Спасибо DarkKingBoo с форума.)
    local player = builder.prefab
    builder.AnimState:SetBank("wilson")
    builder.AnimState:SetBuild(player)
   
    builder.soundsname = (player)
end

@makar5000  "builder" = "owner". So where is my reward :D.

Thanks. I'll try it first, ok?

  • Like 1
Link to comment
Share on other sites

9 minutes ago, zUsername said:

local function  OnEquipWils(inst, builder)
 
    local spawn_fx = SpawnPrefab("spawn_fx_medium")
    spawn_fx.Transform:SetPosition(inst.Transform:GetWorldPosition() )
   
    SetSkinMode(builder.AnimState, "wilson", "wilson", builder.components.skinner:GetClothing(), nil, "wilson")
    --inst.soundsname = "wilson"
   
        local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
        if owner then
            local sanity = owner.components.sanity
            if sanity then
                sanity:DoDelta(-10,false)
            end
        end
       
    --owner.talker_path_override = "dontstarve_DLC001/characters/"
    builder.soundsname = "wilson"
end
 
local function OnUnequip(inst, builder)
 
    local spawn_fx = SpawnPrefab("spawn_fx_medium")
    spawn_fx.Transform:SetPosition(inst.Transform:GetWorldPosition() )
   
    --Возвращаем прежнюю анимацию! (Спасибо DarkKingBoo с форума.)
    local player = builder.prefab
    builder.AnimState:SetBank("wilson")
    builder.AnimState:SetBuild(player)
   
    builder.soundsname = (player)
end

@makar5000  "builder" = "owner". So where is my reward :D.

Oh yeah, it's working! Thaks! Give me your steam trade link, and I'll give you some skins! :)

 

  • Like 1
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...