Get moods: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
Bale (talk | contribs)
r12060
 
m changed wording because the cli command does not return the exact same list as the function
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
#vardefine:name|get_moods}}{{
#vardefine:name|get_moods}}{{
#vardefine:return_type|string [int]}}{{
#vardefine:return_type|string [int]}}{{
#vardefine:aggregate|yes}}{{
#vardefine:aggregate|yes}}{{FunctionPage|
 
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|


Line 15: Line 13:


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|
cli_equiv=The CLI command <code> mood listall </code> will print the same list in the CLI.|
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 (except for composite moods) in the CLI.|


see_also={{SeeAlso|my_effects|have_effect}}|
see_also={{SeeAlso|my_effects|have_effect}}|
}}
}}


[[Category:Adventuring]]
[[index.php?title=Category:Adventuring]]

Latest revision as of 20:50, 24 August 2026

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 (except for composite moods) in the CLI.

See Also

my_effects() | have_effect()


index.php?title=Category:Adventuring