rons0n Posted December 11, 2017 Share Posted December 11, 2017 So this is a very odd request so bear with me, is there a way to change the character's voice sound as soon as he crafts a specific item? For example, If Im wicker bottom and i craft this item, suddenly my voice is wendy. Not its not a consumable, this effect will happen as soon as he/she crafts the item. If anyone can help me with this odd request i'll be greatful. Link to comment Share on other sites More sharing options...
. . . Posted December 11, 2017 Share Posted December 11, 2017 I think something like this would work hopefully ! local function Craft_Youritem(inst, data) if not data.item.prefab == "youritem" then return elseif data.item.prefab == "youritem" then inst.soundsname = "yoursoundname" end end --inside master_postinit inst:ListenForEvent("builditem", Craft_Youritem) Link to comment Share on other sites More sharing options...
rons0n Posted December 11, 2017 Author Share Posted December 11, 2017 It didnt work unfortunately, this is what I did. local assets = { Asset( "ANIM", "anim/sample.zip" ), Asset( "ANIM", "anim/ghost_sample_build.zip" ), Asset("ATLAS", "images/inventoryimages/sample_switch.xml"), Asset("IMAGE", "images/inventoryimages/sample_switch.tex"), } local function onbuilt(inst, builder) -- builder:MakeWillow() SetSkinMode(builder.AnimState, "sample", "sample", builder.components.skinner:GetClothing(), nil, "sample") inst:Remove() end local function craft_sample_switch(inst, data) if not data.item.prefab == "sample_switch" then return elseif data.item.prefab == "sample_switch" then inst.soundsname = "sample" end end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst:AddTag("CLASSIFIED") inst.persists = false inst:DoTaskInTime(0, inst.Remove) if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "sample_switch" inst.components.inventoryitem.atlasname = "images/inventoryimages/sample_switch.xml" inst:ListenForEvent("builditem", craft_sample_switch) inst.OnBuiltFn = onbuilt return inst end return Prefab("sample_switch", fn, assets) Seems pretty straight forward to me but maybe im missing the obvious? Link to comment Share on other sites More sharing options...
. . . Posted December 11, 2017 Share Posted December 11, 2017 (edited) maybe this would work? you can also test using an actual prefab like "axe" & do something like a DoDelta to make sure it works local function craft_sample_switch(inst, data) if data.item.prefab == "youritem" then inst.soundsname = "yoursoundname" end end oh wait, is this for a character or an item? because code I gave is supposed to go in the YOURCHAR.lua I don't think it works with a other prefab (I could be mistaken though) Edited December 11, 2017 by SuperDavid Link to comment Share on other sites More sharing options...
rons0n Posted December 11, 2017 Author Share Posted December 11, 2017 My apologies yeah this is for an item not a character. And yeah unfortunately that method didnt work. Totally my bad for not specifying. But thank you a bunch as this'll help players who wanted to do it the character way regardless. I still need help and if you have other ideas ill be thankful Link to comment Share on other sites More sharing options...
. . . Posted December 11, 2017 Share Posted December 11, 2017 so I don't know how to make code for the item changing the character's voice the closest thing I know to what you want to achieve would be inside modmain.lua AddPlayerPostInit(function(inst, data) inst:ListenForEvent("builditem", function(inst, data) if data.item.prefab == "YOURITEM" then inst.soundsname = "sample" end end) end) if you want characters to get specific voices like wickerbottom's voice changing into wendy then you can use elseif & stuff with checks for what's the player's prefab character to give them the specific voice & stuff. I think this should work basically same way as if the item was changing the voice of the player Link to comment Share on other sites More sharing options...
rons0n Posted December 11, 2017 Author Share Posted December 11, 2017 (edited) Thanks a million David. It worked! It's a rather simple mod but I appreciate the help you've done. I'll give my thanks! Edit: Voila and its done! Simple build switcher with the official characters. So enjoy playing as Wickerbottom but with the appearence of Wendy!(Or any other character for that matter) http://steamcommunity.com/sharedfiles/filedetails/?id=1229049473&searchtext= Edited December 12, 2017 by rons0n 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