Difference between revisions of "My inebriety"

From Kolmafia
Jump to navigation Jump to search
imported>Efilnikufecin
imported>Zarqon
(added more examples and not logged in info)
Line 1: Line 1:
 
[[int]] [[my_inebriety()]]
 
[[int]] [[my_inebriety()]]
  
This function returns the logged-in character's current level of drunkenness as an [[int]].  This information, combined with the character's [[inebriety_limit()]], is vital for any script which intends to drink for the character, but without overdrinking.
+
This function returns the logged-in character's current level of drunkenness as an [[int]].  Common uses include 1) checking to see if you are drunk:
  
An example:
 
 
<code>
 
<code>
if([[inebriety_limit()]] - [[my_inebriety()]] < 5) {
+
  if ([[my_inebriety()]] > [[inebriety_limit()]]) abort("You are too plastered to continue.");
  [[int]] advisable = [[inebriety_limit()]] - [[my_inebriety()]] - 1;
+
</code>
  [[drink]](advisable,$[[item]][Ram's Face Lager]);
+
 
}
+
2) With the help of [[inebriety_limit()]], drinking for the character without overdrinking:
 +
 
 +
<code>
 +
  if ([[inebriety_limit()]] - [[my_inebriety()]] < 5) {
 +
    [[int]] advisable = [[inebriety_limit()]] - [[my_inebriety()]] - 1;
 +
    [[drink]](advisable,$[[item]][Ram's Face Lager]);
 +
  }
 +
</code>
 +
 
 +
And 3) drinking as many as possible of something:
 +
 
 +
<code>
 +
  drink(floor(([[inebriety_limit()]]-[[my_inebriety()]]) / 2), $item[shot of peach schnapps]);
 
</code>
 
</code>
 
[[Category:Your Character | My inebriety()]]
 
[[Category:Your Character | My inebriety()]]
[[Category:Ash Functions |My inebriety()]]
+
[[Category:Ash Functions | My inebriety()]]
 +
 
 +
When not logged in, this function returns 0.

Revision as of 05:13, 29 January 2009

int my_inebriety()

This function returns the logged-in character's current level of drunkenness as an int. Common uses include 1) checking to see if you are drunk:

 if (my_inebriety() > inebriety_limit()) abort("You are too plastered to continue.");

2) With the help of inebriety_limit(), drinking for the character without overdrinking:

 if (inebriety_limit() - my_inebriety() < 5) {
   int advisable = inebriety_limit() - my_inebriety() - 1;
   drink(advisable,$item[Ram's Face Lager]);
 }

And 3) drinking as many as possible of something:

 drink(floor((inebriety_limit()-my_inebriety()) / 2), $item[shot of peach schnapps]);

When not logged in, this function returns 0.