Mateuszw93 Posted March 28, 2024 Share Posted March 28, 2024 So lets say We have a Terminal in Sanctuary SancHawthorneTerminal. I want to add narrator to notes in it, so i eddited SancHawthorneSubTerminal1 and in each menu item I added fragment papyrus abcSound.Play(Game.GetPlayer()) thing is when you get back to main menu the sound is still playing. I want to stop it onMenuExit but i have no idea how to do it I also cant find and documentation lest say we have object Terminal i have no idea what exists in that object Link to comment Share on other sites More sharing options...
DieFeM Posted March 28, 2024 Share Posted March 28, 2024 There you have my approach, using the terminal script instead of fragments, though: Scriptname SancHawthorneTerminalScript extends Terminal Struct MenuItemSound Int MenuID {The ID of the menu item (second column)} Sound Sfx {The the sound to play on this menu item} EndStruct ;Property Array, needs to be filled in CK MenuItemSound[] Property MIS Auto ;Global Script Variable Int LastSoundInstance = 0 Event OnMenuItemRun(int auiMenuItemID, ObjectReference akTerminalRef) ; Lets try to stop the previous sound (if any) If LastSoundInstance > 0 Sound.StopInstance(LastSoundInstance) ; The instance doesn't exist anymore, let's clear the value LastSoundInstance = 0 EndIf ; Find the sound struct for the current menu item Int i = MIS.FindStruct("MenuID", auiMenuItemID) ; play the sound and store the current sound instance so it can be stopped when entering another menu item. LastSoundInstance = MIS[i].Sfx.Play(akTerminalRef) EndEvent terminaltestsounds.zip Link to comment Share on other sites More sharing options...
Mateuszw93 Posted March 29, 2024 Author Share Posted March 29, 2024 @DieFeM Thank You, that looks great I'll give it a try. I haven't used terminal script yet, but I guess i can find some tutorial on YT. I was also thinking about global parameters, or maybe there is a wey to get referance to the sound in other way? The SancHawthorneTerminal has a 3 stage menu locations => names => note lets say that i have a script in main Terminal can i get auiMenuItemID as an array [0,1] for example first locations second name? or maybe i should make a script for each location? Link to comment Share on other sites More sharing options...
DieFeM Posted March 29, 2024 Share Posted March 29, 2024 (edited) You need to attach the script to each terminal, the script attached to the parent terminal will not affect to the submenu terminal. So that it would need some way to share the instance ID of the sound in order to stop the sound from other menus (terminals). Id go with a global property. The same script would be attached to all of the terminals in the menu, they would use the same global to store the sound instance ID (but they can use different sounds in their properties), so that when you run a menu item it will stop the sound instance no matter what terminal started it. Scriptname SancHawthorneTerminalScript extends Terminal Struct MenuItemSound Int MenuID {The ID of the menu item (second column)} Sound Sfx {The the sound to play on this menu item} EndStruct ;Property Array, needs to be filled in CK MenuItemSound[] Property MIS Auto {Stores relationship between menu items and sounds} GlobalVariable Property LastSoundInstance Auto {Fill with the same GlobalVariable in all related terminals} Event OnMenuItemRun(int auiMenuItemID, ObjectReference akTerminalRef) ; Lets try to stop the previous sound (if any) If LastSoundInstance.GetValueInt() > 0 Sound.StopInstance(LastSoundInstance.GetValueInt()) ; The instance doesn't exist anymore, let's clear the value LastSoundInstance.SetValueInt(0) EndIf ; Find the sound struct for the current menu item Int i = MIS.FindStruct("MenuID", auiMenuItemID) ;Check if it found a valid item in the array (I'm testing with no sounds in submenus) If i >= 0 ; play the sound and store the current sound instance so it can be stopped when entering another menu item. LastSoundInstance.SetValueInt(MIS[i].Sfx.Play(akTerminalRef)) EndIf EndEvent terminaltestsounds_global.zip Edited March 29, 2024 by DieFeM Express myself appropriately to avoid confusion Link to comment Share on other sites More sharing options...
Mateuszw93 Posted March 29, 2024 Author Share Posted March 29, 2024 @DieFeM It works great thank You! last question Is there a list of avaible events for all objects? Link to comment Share on other sites More sharing options...
DieFeM Posted March 29, 2024 Share Posted March 29, 2024 The wiki at https://wiki.bethesda.net/, but its down for maintenance. Fortunately for us there's a clone https://falloutck.uesp.net/wiki/ObjectReference_Script Check each object page for a list of functions and events, by hierarchy they inherit, so for example an Actor script will be able to use ObjectReference functions and events. There you have a list of objects: https://falloutck.uesp.net/wiki/Category:Script_Objects Link to comment Share on other sites More sharing options...
Recommended Posts