doctorzero0 Posted February 21, 2020 Share Posted February 21, 2020 I'm pretty much at my wit's end with this one. To sum up, here's the script: Scn NoticeBoardUnderworldTestScript Short Button BEGIN OnActivate if IsActionRef player == 1 showMessage NoticeUnderworldMainMessageendif END BEGIN GameMode set Button to GetButtonPressed if button == 0showmessage NoticeUnderworld01Messageelseif button == 1showmessage NoticeUnderworld02Messageelseif button == 2showmessage NoticeUnderworld03Messageelseif button == 3showmessage NoticeUnderworld04Messageelseif button == 4showmessage NoticeUnderworld05Messageelseif button == 5endif END Works so far until it shows the second message - for instance, if I select NoticeUnderworld01Message. The message appears, but when I try to exit it it instantly pops up again no matter how many times I try, forcing me to exit the game entirely. I have no idea why it does this--I've looked through similar scripts already in the GECK and I've seen nothing that indicates I'm doing something out of the ordinary. Any help would be appreciated. Link to comment Share on other sites More sharing options...
dubiousintent Posted February 21, 2020 Share Posted February 21, 2020 You are missing one conditional test, for a button value of "-1" which is returned when "GetButtonPressed" is called after a ShowMessage button has been pressed. You probably want that to be your "else" (fall-through) condition instead of "elseif button == 5". Put a debug message there or more closely follow the example in the GECKWiki until you are certain you have this working correctly. -Dubious- Link to comment Share on other sites More sharing options...
WarMachineDD7 Posted February 21, 2020 Share Posted February 21, 2020 Question before it's fixed, if you select option 2 and get the 2nd message, does the 2nd message repeat over and over or does it change to the 1st message? I'm just wondering if the GetButtonPressed method fails entirely or if it defaults to 0, because it would explain why the messages repeat over and over. Consider also using the awaitingInput variable shown in the GetButtonPressed example script to stop listening for a button press. Link to comment Share on other sites More sharing options...
doctorzero0 Posted February 22, 2020 Author Share Posted February 22, 2020 To answer WarMachine, it actually does change to the first message. I will never understand scripting. As for dubiousintent, the example in the wiki actually worked, thanks. I want to know why I never came across that page despite several hours of searching. Freaking internet. Link to comment Share on other sites More sharing options...
WarMachineDD7 Posted February 22, 2020 Share Posted February 22, 2020 (edited) Ok, here's what I think was happening: "Begin GameMode" will make everything inside it run once every frame, over and over without stopping. That entire part of the code with the GetButtonPressed and the if-else statements keeps running again and again. So when the code runs for the first time and you make a selection and show either of the 5 messages you created, the code runs again, and checks for a button press again, and what did you select that second time? The OK button, meaning that GetButtonPressed returned a 0 (because you selected the first option of the new message that appeared after your first selection), then it shows NoticeUnderworld01Message with an OK button, and when you press that, GetButtonPressed returns another 0, and it keeps repeating forever. GetButtonPressed will return -1 only when no selection is made, or when the ShowMessage function hasn't been used, but since you called ShowMessage to show the new messages after a selection was made, you let GetButtonPressed listen for an input again, allowing it to return another 0 if you pressed the OK button. I hope that's clear. Edited February 22, 2020 by WarMachineDD7 Link to comment Share on other sites More sharing options...
Recommended Posts