Difference between revisions of "User confirm"

From Kolmafia
Jump to navigation Jump to search
imported>Icon315
(Fixed, added an example)
imported>StDoodle
m (Reverted edits by Icon315 (Talk) to last revision by StDoodle)
Line 20: Line 20:
 
code1={{CodeSample|
 
code1={{CodeSample|
 
title=Code Sample|
 
title=Code Sample|
description=A check to see if the user truly wants to execute a script. You would use the following in a breakfast script, at the bottom after all the none adventuring things are done.|
+
description=A check to see if the user truly wants to execute a script.|
 
code=
 
code=
 
<syntaxhighlight>
 
<syntaxhighlight>
if (!user_confirm("Are you sure you want to proceed with using adventures?") )
+
if (!user_confirm("Are you sure you want to proceed with executing this script?") {
{
+
   abort("Script execution canceled by user.");
   abort("Guess that "+ my_name() +" doesn't want to waste adventures");
 
}
 
 
 
cli_execute ("adv * McMillicancuddy's Farm");
 
 
 
cli_execute ("hermit * clover");
 
 
 
 
</syntaxhighlight>}}|
 
</syntaxhighlight>}}|
  
 
}}
 
}}

Revision as of 18:14, 9 April 2010



Function Syntax

boolean user_confirm(string message )

  • message is the text to display in the confirmation pop-up

Presents the user with a pop-up dialog box with the text in message (can use escaped characters, such as "\n" for a newline); returns true if the user selects "Yes" and false if the user selects "No."

Please use these sparingly, as it can defeat the purpose of scripting if the user must constantly provide information during execution.

Code Sample

A check to see if the user truly wants to execute a script.

if (!user_confirm("Are you sure you want to proceed with executing this script?") {
  abort("Script execution canceled by user.");