Wonderlarr Posted February 16, 2021 Share Posted February 16, 2021 Simple enough question here, is there some way I can use RemapSoundEvent outside of modmain? I want to be able to play a different sound than normal that's played when frozen, but since that's part of the stategraphs, I can't easily replace it. I figured out I could do this with the use of RemapSoundEvent, but I only want it to take effect for the split second I actually use the different sound effect, after I want it to return to normal. I tried using RemapSoundEvent( "dontstarve/common/freezecreature", "icestomp/sound/activate" ) but it threw an error, saying RemapSoundEvent is not declared. Do I need to require something at the beginning of my prefab code? Link to comment https://forums.kleientertainment.com/forums/topic/127134-can-i-use-remapsoundevent-outside-of-modmain/ Share on other sites More sharing options...
Bigfootmech Posted February 16, 2021 Share Posted February 16, 2021 (edited) At the chance to land myself in doo-doo for bad coding practice Two ways I can think of, off the top of my head: 1. Pass the function from modmain (variables/parameters can be functions ) ie: local myFunction = function(parameter) -- some code end myFunction(enterParameter) is totally valid so is local myFunction = function(parameter) -- some code end local anotherFunction = function() -- some code end myFunction(anotherFunction) 2. Find where RemapSoundEvent is declared by text searching accross all files in /scripts/ In this case, it seems to be on TheSim:RemapSoundEvent(name, new_name) TheSim is a C-side object (userdata), and sits on GLOBAL. I'm not 100% sure, but for my imported class, GLOBAL become my new normal environment. so, I think there's a 50/50 shot that this would work: TheSim:RemapSoundEvent( "dontstarve/common/freezecreature", "icestomp/sound/activate" ) Note: I haven't considered in-depth the problem you're having. I'm only responding to the title more or less. There may be a better solution to your actual problem. Edited February 16, 2021 by Bigfootmech 1 Link to comment https://forums.kleientertainment.com/forums/topic/127134-can-i-use-remapsoundevent-outside-of-modmain/#findComment-1429878 Share on other sites More sharing options...
penguin0616 Posted February 16, 2021 Share Posted February 16, 2021 3 hours ago, Bigfootmech said: TheSim:RemapSoundEvent( "dontstarve/common/freezecreature", "icestomp/sound/activate" ) Yep, that's pretty much all you need. 1 1 Link to comment https://forums.kleientertainment.com/forums/topic/127134-can-i-use-remapsoundevent-outside-of-modmain/#findComment-1429924 Share on other sites More sharing options...
CarlZalph Posted February 17, 2021 Share Posted February 17, 2021 For other functions, look at modutil.lua, this file contains the default sandbox environment for all modmain files. env.RemapSoundEvent = function(name, new_name) initprint("RemapSoundEvent", name, new_name) TheSim:RemapSoundEvent(name, new_name) end For example on seeing how the remap works. 2 Link to comment https://forums.kleientertainment.com/forums/topic/127134-can-i-use-remapsoundevent-outside-of-modmain/#findComment-1429950 Share on other sites More sharing options...
Wonderlarr Posted February 17, 2021 Author Share Posted February 17, 2021 Ah, I see now. I wasn't clear on how the scopes in DST worked, this clears a lot of things up! Now I just need to figure out the kinks in using RemapSoundEvent in the way I am. 2 Link to comment https://forums.kleientertainment.com/forums/topic/127134-can-i-use-remapsoundevent-outside-of-modmain/#findComment-1429959 Share on other sites More sharing options...
Wonderlarr Posted February 17, 2021 Author Share Posted February 17, 2021 18 hours ago, Bigfootmech said: Note: I haven't considered in-depth the problem you're having. I'm only responding to the title more or less. There may be a better solution to your actual problem. I know I closed this already, but I do know a better way I could do this, which would be to make my own state I could go to whenever the actions happens, which negates the original sound entirely, but that's too hard lol, an this works. Link to comment https://forums.kleientertainment.com/forums/topic/127134-can-i-use-remapsoundevent-outside-of-modmain/#findComment-1430077 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