Jump to content

Need help with custom message menu


doctorzero0

Recommended Posts

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 NoticeUnderworldMainMessage
endif
END
BEGIN GameMode
set Button to GetButtonPressed
if button == 0
showmessage NoticeUnderworld01Message
elseif button == 1
showmessage NoticeUnderworld02Message
elseif button == 2
showmessage NoticeUnderworld03Message
elseif button == 3
showmessage NoticeUnderworld04Message
elseif button == 4
showmessage NoticeUnderworld05Message
elseif button == 5
endif

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

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

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

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

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 by WarMachineDD7
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...