Mattiewagg Posted January 17, 2015 Author Share Posted January 17, 2015 Is it possible to set the in-game audio volume through scripting? For example, if you wanted to play a custom piece of music for a short amount of time.Also, why isn't this thread stickied yet?I very recently found something like this, but I can't recall the name. There IS a way to play music via script. I'd check the CK wiki. When I get home I'll check on my PC. And I have no idea. I may contact a different mod. Perhaps they think there are already too many pinned, pinned threads aren't noticed as much, or they just haven't noticed this one. Link to comment Share on other sites More sharing options...
Mattiewagg Posted January 17, 2015 Author Share Posted January 17, 2015 Can anyone make me an example script that does this?: After X hours of game time had passed, increase value of a variable by Y. @Matt Scriptname SkyEndWeight extends ObjectReference Actor Property PlayerRef autoKeyword Property Drink autoKeyword Property Food autoGlobalVariable Property FatGainedDay autoGlobalVariable Property DaysWithoutEat autoFloat Property Starving auto Float Property CountDrink autoFloat Property CountFood autoFloat Property Fat auto ;Function SetWeight(float weight) native;float Function GetWeight() native;Function QueueNiNodeUpdate() native Keyword Property Vampire auto Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) if akBaseObject as Potion && akBaseObject.HasKeyword(Drink)Fat= FatGainedDay.GetValue()CountDrink=CountDrink+0.5Fat=Fat+CountDrinkFatGainedDay.SetValue(Fat)CountDrink=0endif if akBaseObject as Potion && akBaseObject.HasKeyword(FOOD)Fat=FatGainedDay.GetValue()CountFood=CountFood+1Fat=Fat+CountFoodFatGainedDay.SetValue(Fat)CountFood=0endif EndEvent Event OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime)PlayerRef.UnEquipAll() if Starving>0Debug.Messagebox("I'm starving, I have lost weight.")elseif Starving == 0Debug.Messagebox("I've gained " + FatGainedDay.GetValue()/10 + " kilograms.")endif EndEvent Event OnSleepStop(bool abInterrupted) if PlayerRef.HasKeyword(Vampire)==0 if FatGainedDay.GetValue()>9FatGainedDay.SetValue(9)PlayerRef.GetActorBase().SetWeight(PlayerRef.GetWeight()+FatGainedDay.GetValue()/10)PlayerRef.QueueNiNodeUpdate()float NeckDelta= PlayerRef.GetWeight()+FatGainedDay.GetValue()/10PlayerRef.UpdateWeight(NeckDelta)FatGainedDay.SetValue(0)endif if FatGainedDay.GetValue()>=7.5 && FatGainedDay.GetValue()<=9PlayerRef.GetActorBase().SetWeight(PlayerRef.GetWeight()+FatGainedDay.GetValue()/10)PlayerRef.QueueNiNodeUpdate()float NeckDelta= PlayerRef.GetWeight()+FatGainedDay.GetValue()/10PlayerRef.UpdateWeight(NeckDelta)FatGainedDay.SetValue(0)endif if FatGainedDay.GetValue()>=6 && FatGainedDay.GetValue()<=7.5PlayerRef.GetActorBase().SetWeight(PlayerRef.GetWeight()+FatGainedDay.GetValue()/10)PlayerRef.QueueNiNodeUpdate()float NeckDelta= PlayerRef.GetWeight()+FatGainedDay.GetValue()/10PlayerRef.UpdateWeight(NeckDelta)FatGainedDay.SetValue(0)endif if FatGainedDay.GetValue()>=4.5 && FatGainedDay.GetValue()<=6; Any value between 4.5 and 6 means you keep your current weightFatGainedDay.SetValue(0)endif if FatGainedDay.GetValue()>=3.5 && FatGainedDay.GetValue()<=4.5PlayerRef.GetActorBase().SetWeight(PlayerRef.GetWeight()-FatGainedDay.GetValue()/10+0.5)PlayerRef.QueueNiNodeUpdate()float NeckDelta= PlayerRef.GetWeight()-FatGainedDay.GetValue()/10+0.5PlayerRef.UpdateWeight(NeckDelta)FatGainedDay.SetValue(0)endif if FatGainedDay.GetValue()>=2 && FatGainedDay.GetValue()<=3.5PlayerRef.GetActorBase().SetWeight(PlayerRef.GetWeight()-FatGainedDay.GetValue()/10+1)PlayerRef.QueueNiNodeUpdate()float NeckDelta= PlayerRef.GetWeight()-FatGainedDay.GetValue()/10+1PlayerRef.UpdateWeight(NeckDelta)FatGainedDay.SetValue(0)endif if FatGainedDay.GetValue()>=0 && FatGainedDay.GetValue()<=2PlayerRef.GetActorBase().SetWeight(PlayerRef.GetWeight()-FatGainedDay.GetValue()/10+2)PlayerRef.QueueNiNodeUpdate()float NeckDelta= PlayerRef.GetWeight()-FatGainedDay.GetValue()/10+2PlayerRef.UpdateWeight(NeckDelta)FatGainedDay.SetValue(0)endif if FatGainedDay.GetValue()==0Starving = Starving + 1elseif FatGainedDay.GetValue()!=0Starving = 0endif if Starving == 14PlayerRef.DamageActorValue("Health",9999999999)endif endifEndEvent ; Function UpdateWeight(float neckDelta) nativeInt Property Once auto Event OnInit()Once=1Starving = 0StatusChecks()EndEvent Event onRaceSwitchComplete()Once=1Starving = 0StatusChecks()EndEvent Function StatusChecks()RegisterForSingleUpdate(5.0)EndFunction Event OnUpdate()if PlayerRef.HasKeyword(Vampire)==0if Once==1PlayerRef.UnEquipAll()Float NeckDelta =0PlayerRef.GetActorBase().SetWeight(0)PlayerRef.QueueNiNodeUpdate()PlayerRef.UpdateWeight(NeckDelta)once==0UnRegisterForUpdate()endifendifEndEvent This is the complete script, I was right, OnUpdate events are paused during showracemenu, so this works like a charm. And I did have to use the UpdateWeight function because the neck did look pretty odd =p, I don't know if QueueNiNode is still necessary or if it has any ramifications if kept there, but I'll just keep it there incase. Because of the keywords I added to all the food items in the game it correctly checks if I'm drinking or eating. The only thing that I haven't tested yet is the OnSleepEnd and OnSleepStart events because I haven't had time XD, at this point I just wished I had testers. Additional: Is it possible to advance the rate at which time passes in Papyrus? And how? float X int Y int myVar Event OnInit() RegisterForSingleUpdateGameTime(X); X is a float for how many hours to wait EndEvent Event OnUpdateGameTime() myVar += Y RegisterForSingleUpdateGameTime(X); only have this line if you want to keep repeating this var change EndEvent As for changing in game passing time - yes it's possible. Check for a function to change Timescale on the CK Wiki. Or, it may be a Global the way GameTime is. If that is the case, look for Globals with Timescale in the name. You can use SetValue with this global to set the speed of time ingame. Don't go below 5 no matter what, though I'm not sure on the limit for how high. Link to comment Share on other sites More sharing options...
Kerberus14 Posted January 17, 2015 Share Posted January 17, 2015 I have a problem with the OnUpdate even in that script, it repeats exactly 9 times for some reason, even though I change 'Once' to 0.. Link to comment Share on other sites More sharing options...
Mattiewagg Posted January 17, 2015 Author Share Posted January 17, 2015 I have a problem with the OnUpdate even in that script, it repeats exactly 9 times for some reason, even though I change 'Once' to 0..What do you mean "Once"? In which script? Link to comment Share on other sites More sharing options...
Kerberus14 Posted January 17, 2015 Share Posted January 17, 2015 The script I have in the Spoiler. I have tested with only an OnInit event that calls the function to registerforupdate once every 15 seconds, and unregister it after it happens, and it still happens more than 1 time. Link to comment Share on other sites More sharing options...
Kerberus14 Posted January 17, 2015 Share Posted January 17, 2015 Something extremely odd is going on, even if I haven't called the function it will still happen now. Link to comment Share on other sites More sharing options...
Mattiewagg Posted January 17, 2015 Author Share Posted January 17, 2015 Two things: DON'T use RegisterForUpdate of any kind. JUST RegisterForSingleUpdates in a loop (calling it again in the OnUpdate): Secondly, DON'T call more than a couple of functions in the OnInit. It may overload and not be able to handle it all. Link to comment Share on other sites More sharing options...
Kerberus14 Posted January 17, 2015 Share Posted January 17, 2015 (edited) I didn't, and I used RegisterForSingleUpdate then I Unregistered inside the OnUpdate event, but even if I don't call the Function for registering the event the OnUpdate event will still happen regardless, every 1 second or so, it eventually stops, but it runs a whopping 9 times or more when it is only supposed to run once or not at all, lol. Event OnInit() StatusChecks() Debug.MessageBox("ATTENTION!: This overhaul allows you to manage your body weight by eating and drinking if you are not a vampire and/or undead. If you haven't eaten for 14 days and your weight is 0 you will die. The ratio for Drinks is 4 to 1, the ratio for Food is 1 to 1, you need to consume at least 4-6 food items or drink 4 times that much to keep your current weight, anything above that will increase your weight, anything less than that will decrease your weight. Your weight changes whenever you wake up after going to sleep. Your items are also unequipped when you go to sleep to avoid bugs.") EndEvent Function StatusChecks() RegisterForUpdate(10.0) EndFunction Event OnUpdate() if PlayerRef.HasKeyword(Vampire)==0 PlayerRef.UnEquipAll() Float NeckDelta =0 PlayerRef.GetActorBase().SetWeight(0) PlayerRef.QueueNiNodeUpdate() PlayerRef.UpdateWeight(NeckDelta) Debug.MessageBox("stuff") endif UnRegisterForUpdate() EndEvent This is all I have. This OnUpdate happens more than once. Edited January 17, 2015 by Kerberus14 Link to comment Share on other sites More sharing options...
Mattiewagg Posted January 17, 2015 Author Share Posted January 17, 2015 No. You didn't use RegisterForSingleUpdate. You used RegisterForUpdate. Unregistering for it doesn't matter - just use a single update. Either you don't need it to unregister at all if you want to do it once, or you just call another Single Update inside the OnUpdate. Link to comment Share on other sites More sharing options...
Kerberus14 Posted January 17, 2015 Share Posted January 17, 2015 (edited) Oh, I copied the wrong snippet, it's because I tested both versions with RegisterForUpdate and RegisterForSingleUpdate to check if that was the problem, but it still behaves completely the same. The other scripts that use the same event seem to work just fine... I can confirm that this event stops one of my other script's OnUpdate events from working. What? Edited January 17, 2015 by Kerberus14 Link to comment Share on other sites More sharing options...
Recommended Posts