Restore mp: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
mNo edit summary
imported>Fronobulax
No edit summary
 
(One intermediate revision by one other user not shown)
Line 17: Line 17:


function_description=Restores your MP, following your current recovery settings as closely as possible. This function only attempts to surpass {{pspan|target}}, not to arrive as closely as possible to it. If your current KoLmafia recovery settings are lower than your current MP (or off), this function will restore the bare minimum necessary to reach {{pspan|target}} using the restores you have checked. If, however, you have your recovery setting set to "Try to recover up to 100% mana," this function will follow that preference if possible.</p>
function_description=Restores your MP, following your current recovery settings as closely as possible. This function only attempts to surpass {{pspan|target}}, not to arrive as closely as possible to it. If your current KoLmafia recovery settings are lower than your current MP (or off), this function will restore the bare minimum necessary to reach {{pspan|target}} using the restores you have checked. If, however, you have your recovery setting set to "Try to recover up to 100% mana," this function will follow that preference if possible.</p>
<p>If {{pspan|target}} is zero then it will restore MP according to KoLmafia's recovery settings.</p>
<p>If {{pspan|target}} is zero then it will restore MP according to KoLmafia's recovery settings.  Note that the definition of "current recovery settings" may be different if a {{pspan|recoveryScript}} is specified.</p>
<p>This function will do nothing and return false if you have not checked any restore items. Otherwise, this function returns true if your MP is at or equal to {{pspan|target}} when finished. If {{pspan|target}} is set above your current max MP, this function will attempt to restore to that amount and report its success based on that goal, not the number used for {{pspan|target}}.|
<p>If a recoveryScript is present and returns TRUE then this function returns TRUE.  If a recoveryScript is present and returns FALSE then this function returns the results of mafia's internal restoration attempt.  If no recoveryScript is specified then the results of mafia's internal restoration attempt will be returned.
 
If you use a recoveryScript and call restore_mp then it is your responsibility to deal with the possibility that restore_mp will return TRUE but the desired amount of MP will not have been reached.
|


code1={{CodeSample|
code1={{CodeSample|
Line 33: Line 36:
see_also={{SeeAlso|my_hp|my_mp|my_maxhp|my_maxmp|restore_hp}}|
see_also={{SeeAlso|my_hp|my_mp|my_maxhp|my_maxmp|restore_hp}}|
cli_equiv=The CLI command "restore" has similar functionality.|
cli_equiv=The CLI command "restore" has similar functionality.|
special=Note: the return value can be over-ridden by a [[Miscellaneous_ASH_Features#Recovery_.28recoveryScript.29|recoveryScript]] if in use. If your script's behavior changes based on the return value of this function, it is recommended that you explicitly state which, if any, recoveryScripts it can support when publicly releasing your script.
}}
}}


[[Category:Skills and Effects]]
[[Category:Skills and Effects]]

Latest revision as of 21:40, 17 December 2011

Function Syntax

boolean restore_mp(int target )

  • target is the minimum MP desired after the function is run.

Restores your MP, following your current recovery settings as closely as possible. This function only attempts to surpass target, not to arrive as closely as possible to it. If your current KoLmafia recovery settings are lower than your current MP (or off), this function will restore the bare minimum necessary to reach target using the restores you have checked. If, however, you have your recovery setting set to "Try to recover up to 100% mana," this function will follow that preference if possible.

If target is zero then it will restore MP according to KoLmafia's recovery settings. Note that the definition of "current recovery settings" may be different if a recoveryScript is specified.

If a recoveryScript is present and returns TRUE then this function returns TRUE. If a recoveryScript is present and returns FALSE then this function returns the results of mafia's internal restoration attempt. If no recoveryScript is specified then the results of mafia's internal restoration attempt will be returned. If you use a recoveryScript and call restore_mp then it is your responsibility to deal with the possibility that restore_mp will return TRUE but the desired amount of MP will not have been reached.

Code Sample

This sample attempts to restore your MP to full.

if (my_mp() < my_maxmp()) {
   restore_mp(my_maxmp());
}

CLI Equivalent

The CLI command "restore" has similar functionality.

See Also

my_hp() | my_mp() | my_maxhp() | my_maxmp() | restore_hp()

Special

Note: the return value can be over-ridden by a recoveryScript if in use. If your script's behavior changes based on the return value of this function, it is recommended that you explicitly state which, if any, recoveryScripts it can support when publicly releasing your script.