Difference between revisions of "Get moods"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
(r12060)
 
imported>Eliteofdelete
 
Line 15: Line 15:
  
 
function_description=This function returns an integer indexed list of all currently defined mood names.|
 
function_description=This function returns an integer indexed list of all currently defined mood names.|
needscode=yes|
+
code1={{CodeSample|
 +
title=Code Samples|
 +
description=Gives a list of your current saved moods. Also switches to the wiki's example mood and lists its triggers, if available.|
 +
code=
 +
<syntaxhighlight>
 +
string[int] moods;
 +
moods = get_moods();
 +
print("A list of all your current moods:", "blue");
 +
foreach it, mood in moods {
 +
  print(mood);
 +
  if (mood == "moxieleveling") {
 +
      print("Wiki example mood 'MoxieLeveling' detected, switching to it now.", "blue");
 +
      cli_execute("mood "+mood);
 +
      print("It currently has the following triggers:", "blue");
 +
      cli_execute("trigger list");
 +
  }
 +
}     
 +
</syntaxhighlight>|
 +
moreinfo=
 +
The wiki example of mood generation can be found on the cli_execute page.
 +
}}|
 
cli_equiv=The CLI command <code> mood listall </code> will print the same list in the CLI.|
 
cli_equiv=The CLI command <code> mood listall </code> will print the same list in the CLI.|
  

Latest revision as of 03:35, 14 January 2015

Function Syntax

string [int] get_moods()

This function returns an integer indexed list of all currently defined mood names.

Code Samples

Gives a list of your current saved moods. Also switches to the wiki's example mood and lists its triggers, if available.

string[int] moods;
moods = get_moods();
print("A list of all your current moods:", "blue");
foreach it, mood in moods {
   print(mood);
   if (mood == "moxieleveling") {
      print("Wiki example mood 'MoxieLeveling' detected, switching to it now.", "blue");
      cli_execute("mood "+mood);
      print("It currently has the following triggers:", "blue");
      cli_execute("trigger list");
   }
}

The wiki example of mood generation can be found on the cli_execute page.

CLI Equivalent

The CLI command mood listall will print the same list in the CLI.

See Also

my_effects() | have_effect()