Cunning fox Posted January 9, 2017 Share Posted January 9, 2017 (edited) 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: While my item is eqquiped, player's voice disappears. 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 January 9, 2017 by makar5000 1 Link to comment Share on other sites More sharing options...
chilidawgs Posted January 9, 2017 Share Posted January 9, 2017 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 More sharing options...
zUsername Posted January 10, 2017 Share Posted January 10, 2017 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 . Link to comment Share on other sites More sharing options...
Cunning fox Posted January 10, 2017 Author Share Posted January 10, 2017 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 . Thanks. I'll try it first, ok? 1 Link to comment Share on other sites More sharing options...
zUsername Posted January 10, 2017 Share Posted January 10, 2017 Haha, OK. First time helping people and get reward. Link to comment Share on other sites More sharing options...
Cunning fox Posted January 10, 2017 Author Share Posted January 10, 2017 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 . Oh yeah, it's working! Thaks! Give me your steam trade link, and I'll give you some skins! 1 Link to comment Share on other sites More sharing options...
zUsername Posted January 10, 2017 Share Posted January 10, 2017 Here you are : https://steamcommunity.com/tradeoffer/new/?partner=136262146&token=2pScodWx Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now