KingShelby Posted March 10, 2017 Share Posted March 10, 2017 I'm wanting to have a message box pop up and tell the player what the winning number was. Something like: The winning number was "67". I'll be using an int variable like: int winningnumber The winning number will be randomly generated with getrandompercent I'm looking to get that random number into the message. Link to comment Share on other sites More sharing options...
Ladez Posted March 11, 2017 Share Posted March 11, 2017 (edited) Read the "Formatting messages" section in the article on the ShowMessage function. For you, %.0f or %g are the way to go. Edit: Fixed link. Edited March 11, 2017 by Ladez Link to comment Share on other sites More sharing options...
KingShelby Posted March 11, 2017 Author Share Posted March 11, 2017 Yea I saw that, and its what I need but I'm not sure on how to script it in. I done a bunch of scripting but this will be my first time using %.f. I'll try a few things tonight when I get home. If anyone has tips I'm sure it'll save me some headache. Link to comment Share on other sites More sharing options...
Ladez Posted March 11, 2017 Share Posted March 11, 2017 Include the formatting switch in the text in the message form, like this: "The winning number was %g." Then pass the script variable to the ShowMessage function along with the message, like this: set iWinningNumber to GetRandomPercent ShowMessage WinnerMessage, iWinningNumber Here's an example with NVSE, which allows you to show messages without creating a new message form. NVSE also supports a number of extra switches that can't be used in ordinary message forms. MessageBoxEx "The winning number was %g.", iWinningNumber Link to comment Share on other sites More sharing options...
KingShelby Posted March 11, 2017 Author Share Posted March 11, 2017 Sweet I was close when I had to stop last night. I had the info in the message box just needed to know what else I needed. Thanks for the tip, I'll let you know how it goes. Link to comment Share on other sites More sharing options...
KingShelby Posted March 14, 2017 Author Share Posted March 14, 2017 Include the formatting switch in the text in the message form, like this: "The winning number was %g." Then pass the script variable to the ShowMessage function along with the message, like this: set iWinningNumber to GetRandomPercent ShowMessage WinnerMessage, iWinningNumber Here's an example with NVSE, which allows you to show messages without creating a new message form. NVSE also supports a number of extra switches that can't be used in ordinary message forms. MessageBoxEx "The winning number was %g.", iWinningNumber Thanks a ton for the the info, it worked like a charm. I had initially put the variable after the formatting switch in the message. I had about 3 things all tying in together with the message popping up in the middle of other messages, so I just put the info in like you suggested and had no problems with it at all. This MessageBoxEx looks pretty interesting too. I usually don't ask for much help, but figured it might help me get it figured out quicker so I decided to ask here. Your quick response is very much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts