Quincy Posted January 19 Share Posted January 19 (edited) Hi all, Currently trying to learn how the whole modding dealio works, and am struggling to understand how to add a sound into a function. I have a sound attached to the recipe (i.e. the crafting phase) which works fine, but I would like a separate sound to play at the end of the crafting action (the OnCreate), depending on whether the user succeeded or failed in the craft. Similar to how you get a wood breaking sound if you fail to pick up a crate with carpentry, but I struggled to find that to reference. The current function is below - basically rolls to see if the user succeeds or fails in the craft, and rolls some flavour text options for each. Could anyone help with advising on: How to add a custom sound that plays solely for the player based on success (GemChance>=5), or failure? Where to place these custom sounds in the mod file to permit the function to locate/use them? function Recipe.OnCreate.GemSuccess(items, result, player) local GemChance = ZombRand(1,11); local GemWords = ZombRand(1,7); if GemChance>=5 and GemWords>=1 and GemWords<=2 then player:getInventory():AddItem("Base.AWKGemstone"); player:Say(getText("IGUI_GemSucceed1")); elseif GemChance>=5 and GemWords>=3 and GemWords<=4 then player:getInventory():AddItem("Base.AWKGemstone"); player:Say(getText("IGUI_GemSucceed2")); elseif GemChance>=5 and GemWords>=5 then player:getInventory():AddItem("Base.AWKGemstone"); player:Say(getText("IGUI_GemSucceed3")); elseif GemWords<=3 then player:Say(getText("IGUI_GemFail1")); elseif GemWords>=4 and GemWords<=5 then player:Say(getText("IGUI_GemFail2")); elseif GemWords==6 then player:Say(getText("IGUI_GemFail3")); end end Cheers, Quincy Edited January 19 by Quincy Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted January 19 Share Posted January 19 I believe you would call - player:playSound("SoundName"), not sure if you can just drop an audio file into /media/sound/ or whether it is more complicated than that. The PZ modding discord is probably the best place to ask, lots of knowledge people on there. https://discord.com/invite/SReMnbV4V7 Link to comment Share on other sites More sharing options...
Quincy Posted January 22 Author Share Posted January 22 Cheers Hugo, Ended up stumbling my way into - getSoundManager():PlaySound("GemGet", false, 0.5); - which is working. Can confirm dropping the audio files into media/sound/ works a treat. Appreciate the heads up on the Discord, have signed up there :) 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