RevusHarkings Posted June 25, 2020 Share Posted June 25, 2020 Currently my mod contains two quests. The first quest has a script attached Scriptname TestQuestScript1 extends Quest Event OnInit() RegisterForKey(51) EndEvent Event OnKeyDown(Int KeyCode) If (KeyCode == 51) Debug.Notification("Sending TestEvent NOW!") SendModEvent("TestEvent") Debug.Notification("TestEvent sent") EndIf EndEvent which sends the event when the comma key is pressed. The second quest has a script attached Scriptname TestQuestScript2 extends Quest Event OnInit() RegisterForSingleUpdate(15) EndEvent Event OnUpdate() Debug.MessageBox("Registering for TestEvent") RegisterForModEvent("TestEvent", "OnTestEvent") EndEvent Event OnTestEvent() Debug.MessageBox("Received TestEvent") EndEvent which registers to receive the event. The "Registering for TestEvent" messagebox in the second script pops up, and when I press the comma key both notifications from the first script pop up, but the "Received TestEvent" messagebox never appears. What am I doing wrong? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 25, 2020 Share Posted June 25, 2020 You are lacking the parameters on the Event line. Even if you are not using them, they need to be there for the event to properly function.Working example: Sending Script Event OnKeyDown(Int KeyCode) If KeyCode == abim_IMS_ModActKeyGV.GetValue() If OldMAK != KeyCode OldMAK = KeyCode SendModEvent("abim_HotKeyInitiateEvent") ; Debug.Notification("Initiating secondary script hot key registration") EndIf UnRegisterForAllKeys() EndIf EndEvent Receiving Script Event OnInit() RegisterForModEvent("abim_HotKeyInitiateEvent","OnHotKeyInitiate") MaintUpdate() EndEvent Event OnPlayerLoadGame() RegisterForModEvent("abim_HotKeyInitiateEvent","OnHotKeyInitiate") RegisterForMenu("ContainerMenu") If VersionUpdate > 0.0 MaintUpdate() EndIf EndEvent Event OnHotKeyInitiate(string eventName, string strArg, float numArg, Form sender) UnregisterForAllKeys() Int MAK = abim_IMS_ModActKeyGV.GetValue() as Int If MAK != -1.0 RegisterForKey(MAK) ; Debug.Notification("Hot key registration complete") OnKeyDown(MAK) EndIf EndEvent Link to comment Share on other sites More sharing options...
RevusHarkings Posted June 25, 2020 Author Share Posted June 25, 2020 I updated the second script like you suggested. Scriptname TestQuestScript2 extends Quest Event OnInit() RegisterForSingleUpdate(15) EndEvent Event OnUpdate() Debug.MessageBox("Registering for TestEvent") RegisterForModEvent("OnTestEvent", "TestEvent") EndEvent Event OnTestEvent(string eventName, string strArg, float numArg, Form sender) Debug.MessageBox("Received TestEvent") EndEvent I still get the same result. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 26, 2020 Share Posted June 26, 2020 In your new post of the second script, you've flipped the two parameters for the RegisterForModEvent function call. So... now it won't work because it is registering for the wrong thing. Link to comment Share on other sites More sharing options...
RevusHarkings Posted June 26, 2020 Author Share Posted June 26, 2020 It works now, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts