Difference between revisions of "Craft"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
imported>Bale
m
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{FunctionPage |
+
{{
page_name=craft|
+
#vardefine:name|craft}}{{
function_category=Miscellaneous|
+
#vardefine:return_type|int}}{{
function1_return_type=int |
+
 
function1_parameter1={{Param|string|mode}} |
+
FunctionPage|
function1_parameter2={{Param|int|count}} |
+
name={{#var:name}}|
function1_parameter3={{Param|int|item1}} |
+
 
function1_parameter4={{Param|int|item2}} |
+
function1={{Function|
function1_parameter1_desc=mode can be "combine", "cook", "cocktail", "smith", "jewelry".|
+
name={{#var:name}}|
function1_parameter2_desc=count is how many of each ingredient to use.|
+
aggregate={{#var:aggregate}}|
function1_parameter3_desc=item1 and item2 are the ingredients.|
+
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|string|mode}}|
 +
parameter2={{Param|int|count}} |
 +
parameter3={{Param|item|item1}} |
 +
parameter4={{Param|item|item2}} |
 +
p1desc={{Pspan|mode}} can be "combine", "cook", "cocktail", "smith", "jewelry".|
 +
p2desc={{Pspan|count}} count is how many of each ingredient to use.|
 +
p3desc={{Pspan|item1, item2}} are the ingredients.|}}|
 +
 
 
function_description=This is a raw crafting function that will attempt to craft raw materials without considering the outcome of that crafting. </p>
 
function_description=This is a raw crafting function that will attempt to craft raw materials without considering the outcome of that crafting. </p>
  
<p>It can be useful for specialized tasks such as gaining the "Color Wheel of Yuck" trophy since that requires you to craft many items using different methods to create the same results.
+
<p>It can be useful for specialized tasks such as gaining the "Color Wheel of Yuck" trophy since that requires you to craft many items using different methods to create the same results.</p>
  
It returns the number of each ingredient used. Ideally, this is equal to the
+
<p>It returns the number of each ingredient used. Ideally, this is equal to the
 
"count" parameter, but could be less if, for example, your box servant blew
 
"count" parameter, but could be less if, for example, your box servant blew
 
up, you require box servants, and auto-repair was either disabled or failed.|
 
up, you require box servants, and auto-repair was either disabled or failed.|
 +
 
code1={{CodeSample |
 
code1={{CodeSample |
title=Simple Example|
+
title=Examples|
 
description=Just an example of how to make vials of brown slime in two different ways.|
 
description=Just an example of how to make vials of brown slime in two different ways.|
code=<syntaxhighlight>
+
code=
craft("cook", 1, to_int($item[vial of red slime]), to_int($item[vial of green slime]));
+
<syntaxhighlight>
craft("cook", 1, to_int($item[vial of red slime]), to_int($item[vial of chartreuse slime]));
+
craft("cook", 1, $item[vial of red slime], $item[vial of green slime]);
 +
craft("cook", 1, $item[vial of red slime], $item[vial of chartreuse slime]);
 +
</syntaxhighlight>}}
 +
{{CodeSample |
 +
description=Transmuting wads requires craft() since mafia does not support the recipes.|
 +
code=
 +
<syntaxhighlight>
 +
boolean cook_wad(item it) {
 +
  item [item] to_make;
 +
      to_make [$item[cold wad]] = $item[hot wad];
 +
      to_make [$item[spooky wad]] = $item[cold wad];
 +
      to_make [$item[stench wad]] = $item[spooky wad];
 +
      to_make [$item[sleaze wad]] = $item[stench wad];
 +
      to_make [$item[hot wad]] = $item[sleaze wad];
 +
 
 +
  if(!have_skill($skill[The Way of Sauce])) {
 +
      print("You don't have the skill to transmute wads.", "red");
 +
      return false;
 +
  }
 +
  if(item_amount(to_make[it]) < 1 || item_amount($item[twinkly wad]) < 1) {
 +
      print("To make a "+ it+ " requires a twinkly wad and a "+ to_make[it]+ ". You do not have the ingredients.", "red");
 +
      return false;
 +
  }
 +
 
 +
  print("Cooking a twinkly wad with a "+ it+ " to make a "+ to_make[it]+ ".");
 +
  craft("cook", 1, $item[twinkly wad], to_make[it]);
 +
  return true;
 +
}
 +
</syntaxhighlight>}}|
  
</syntaxhighlight>}} |
 
 
}}
 
}}
 +
 +
[[Category:Item Management]]

Latest revision as of 22:08, 21 May 2010

Function Syntax

int craft(string mode ,int count ,item item1 ,item item2 )

  • mode can be "combine", "cook", "cocktail", "smith", "jewelry".
  • count count is how many of each ingredient to use.
  • item1, item2 are the ingredients.

This is a raw crafting function that will attempt to craft raw materials without considering the outcome of that crafting.

It can be useful for specialized tasks such as gaining the "Color Wheel of Yuck" trophy since that requires you to craft many items using different methods to create the same results.

It returns the number of each ingredient used. Ideally, this is equal to the "count" parameter, but could be less if, for example, your box servant blew up, you require box servants, and auto-repair was either disabled or failed.

Examples

Just an example of how to make vials of brown slime in two different ways.

craft("cook", 1, $item[vial of red slime], $item[vial of green slime]);
craft("cook", 1, $item[vial of red slime], $item[vial of chartreuse slime]);

Transmuting wads requires craft() since mafia does not support the recipes.

boolean cook_wad(item it) {
   item [item] to_make;
      to_make [$item[cold wad]] = $item[hot wad];
      to_make [$item[spooky wad]] = $item[cold wad];
      to_make [$item[stench wad]] = $item[spooky wad];
      to_make [$item[sleaze wad]] = $item[stench wad];
      to_make [$item[hot wad]] = $item[sleaze wad];
   
   if(!have_skill($skill[The Way of Sauce])) {
      print("You don't have the skill to transmute wads.", "red");
      return false;
   }
   if(item_amount(to_make[it]) < 1 || item_amount($item[twinkly wad]) < 1) {
      print("To make a "+ it+ " requires a twinkly wad and a "+ to_make[it]+ ". You do not have the ingredients.", "red");
      return false;
   }
   
   print("Cooking a twinkly wad with a "+ it+ " to make a "+ to_make[it]+ ".");
   craft("cook", 1, $item[twinkly wad], to_make[it]);
   return true;
}