# Production Interface (MakeX)

The [Make-X interface](https://runescape.wiki/w/Make-X) is RuneScape 3's primary production system that allows players to create items in bulk. When you perform an action that opens the Make-X interface, it displays:

![Make-X Interface](https://runescape.wiki/images/thumb/Make-X.png/300px-Make-X.png?23219)

* **Item Information**: Which item you're making, tooltip with equipment stats, and required level
* **Materials**: All required materials and their quantities
* **Values**: Grand Exchange value and high alchemy value
* **Category Items**: Items under the same category (e.g., leather armour, smithing items)
* **Quantity Slider**: Adjustable bar showing how many items you'll make

![Make-X Progress Window](https://runescape.wiki/images/thumb/Make_X_progress_window.png/300px-Make_X_progress_window.png?43b99)

The interface supports production across many skills including:

* **Cooking** - Food preparation and brewing
* **Crafting** - Leatherwork, pottery, gem cutting
* **Smithing** - Armor and weapon creation
* **And many more...**

The KXAPI framework automates interaction with this interface, handling item selection, quantity management, and progress tracking automatically.

### 🚀 Quick Access

The skilling framework is accessed through the `skilling` property on any `BwuScript` or `SuspendableScript`:

```kotlin
class MyScript : SuspendableScript() {
    override suspend fun onLoop() {
        // Access skilling DSL
        val production = this.skilling.production {
            itemName("Iron Sword")
            category("Smithing")
        }
    }
}
```

### 📚 Available Methods

The skilling framework provides three main methods:

* `production(builder)` - Full DSL configuration
* `produce(itemName, category)` - Quick creation
* `advancedProduction(builder)` - Advanced configuration

### 🎨 DSL Pattern (Recommended)

<details>

<summary><strong>DSL Pattern Examples</strong></summary>

#### Basic Production

```kotlin
class MyScript : SuspendableScript() {
    override suspend fun onLoop() {
        val production = this.skilling.production {
            itemName("Iron Sword")
            category("Smithing")
        }
        
        production.produceItem(
            onProgress = { message, current, total, rate, xp ->
                println("${message.message}: $current/$total at $rate/s, +$xp XP")
            },
            onFinished = { totalXp ->
                println("Production finished! Total XP: $totalXp")
            }
        )
    }
}
```

#### Multiple Production Tasks

```kotlin
// Create multiple production tasks
val cooking = this.skilling.production {
    itemName("Shrimp")
    category("Cooking")
}

val smithing = this.skilling.production {
    itemName("Iron Sword")
    category("Smithing")
}

val crafting = this.skilling.production {
    itemName("Leather Gloves")
    category("Crafting")
}
```

#### Quick Production

```kotlin
// Simple one-liner for basic production
val production = this.skilling.produce("Shrimp", "Cooking")
production.produceItem()
```

#### Advanced Production

```kotlin
val production = this.skilling.advancedProduction {
    itemName("Dragon Platebody")
    category("Smithing")
    // Additional configuration options can be added here
}
```

#### Production with Callbacks

```kotlin
val production = this.skilling.production {
    itemName("Clean ranarr")
    category("Clean Herbs")
}

production.produceItem(
    onProgress = { result, current, total, rate, xp ->
        when (result) {
            ProductionResult.CREATION_IN_PROGRESS -> {
                println("Progress: $current/$total items")
                println("Rate: $rate items/second")
                println("XP gained: $xp")
            }
            ProductionResult.ITEM_NOT_FOUND -> {
                println("Item not found in production menu")
            }
            ProductionResult.CATEGORY_NOT_FOUND -> {
                println("Category not found")
            }
            ProductionResult.MISSING_REQUIREMENTS -> {
                println("Missing requirements to produce item")
            }
            ProductionResult.INTERFACE_ERROR -> {
                println("Interface error occurred")
            }
        }
    },
    onFinished = { totalXp ->
        println("Production completed! Total XP gained: $totalXp")
    }
)
```

</details>

### 🔧 Builder Pattern

<details>

<summary><strong>Builder Pattern Examples</strong></summary>

#### Basic Builder Usage

```kotlin
class MyScript : SuspendableScript() {
    override suspend fun onLoop() {
        val builder = ProductionBuilder()
            .itemName("Iron Sword")
            .category("Smithing")
        
        val production = builder.build(this)
        production.produceItem()
    }
}
```

#### Fluent Builder Chain

```kotlin
val production = ProductionBuilder()
    .itemName("Clean ranarr")
    .category("Clean Herbs")
    .build(this)

production.produceItem(
    onProgress = { message, current, total, rate, xp ->
        println("${message.message}: $current/$total")
    }
)
```

#### Builder with Multiple Items

```kotlin
// Create multiple production tasks using builder
val swordProduction = ProductionBuilder()
    .itemName("Iron Sword")
    .category("Smithing")
    .build(this)

val armorProduction = ProductionBuilder()
    .itemName("Iron Platebody")
    .category("Smithing")
    .build(this)
```

#### Builder with Error Handling

```kotlin
try {
    val production = ProductionBuilder()
        .itemName("Dragon Platebody")
        .category("Smithing")
        .build(this)
    
    production.produceItem(
        onProgress = { result, current, total, rate, xp ->
            handleProductionProgress(result, current, total, rate, xp)
        },
        onFinished = { totalXp ->
            println("Production completed with $totalXp XP")
        }
    )
} catch (e: IllegalStateException) {
    println("Configuration error: ${e.message}")
}
```

</details>

### 📊 Production Results

The framework provides detailed result information through `ProductionResult` enum:

| Result                 | Description                       | When It Occurs                     |
| ---------------------- | --------------------------------- | ---------------------------------- |
| `CREATION_IN_PROGRESS` | Production is actively running    | During item creation               |
| `ITEM_NOT_FOUND`       | Item not found in production menu | Item doesn't exist in category     |
| `CATEGORY_NOT_FOUND`   | Production category not found     | Category doesn't exist             |
| `MISSING_REQUIREMENTS` | Missing materials or requirements | Can't produce due to missing items |
| `INTERFACE_ERROR`      | Interface interaction failed      | UI interaction problems            |

### 🎯 Production Methods

<details>

<summary><strong>DSL Methods</strong></summary>

| Method                        | Description               | Parameters                     |
| ----------------------------- | ------------------------- | ------------------------------ |
| `production(builder)`         | Full DSL configuration    | `ProductionBuilder.() -> Unit` |
| `produce(itemName, category)` | Quick production creation | `String, String`               |
| `advancedProduction(builder)` | Advanced configuration    | `ProductionBuilder.() -> Unit` |

</details>

<details>

<summary><strong>Builder Methods</strong></summary>

| Method           | Description                   | Parameters  |
| ---------------- | ----------------------------- | ----------- |
| `itemName(name)` | Set item name                 | `String`    |
| `category(name)` | Set production category       | `String`    |
| `build(script)`  | Build the production selector | `BwuScript` |

</details>

<details>

<summary><strong>Production Type Selector Methods</strong></summary>

| Method                                | Description                   | Parameters                                                            |
| ------------------------------------- | ----------------------------- | --------------------------------------------------------------------- |
| `produceItem(onProgress, onFinished)` | Start production              | `(ProductionResult, Int, Int, Int, Double) -> Unit, (Double) -> Unit` |
| `canProduce()`                        | Check if item can be produced | None                                                                  |

</details>

### 💡 Examples

#### 1. Use DSL for Readability

<pre class="language-kotlin"><code class="lang-kotlin">val production = this.skilling.production {
    itemName("Iron Sword")
    category("Smithing")
<strong>}
</strong>
val production = ProductionBuilder()
    .itemName("Iron Sword")
    .category("Smithing")
    .build(this)
</code></pre>

#### 2. Handle All Production Results

```kotlin
production.produceItem(
    onProgress = { result, current, total, rate, xp ->
        when (result) {
            ProductionResult.CREATION_IN_PROGRESS -> {
                // Handle progress updates
            }
            ProductionResult.ITEM_NOT_FOUND -> {
                // Handle missing item
                println("Item not found, stopping script")
            }
            ProductionResult.MISSING_REQUIREMENTS -> {
                // Handle missing requirements
                println("Missing materials, going to bank")
            }
            // Handle other results...
        }
    }
)
```

#### 3. Use Quick Methods for Simple Tasks

```kotlin
val production = this.skilling.produce("Shrimp", "Cooking")

val production = this.skilling.production {
    itemName("Dragon Platebody")
    category("Smithing")
}
```

#### 4. Check Production Capability

```kotlin
val production = this.skilling.production {
    itemName("Rune Platebody")
    category("Smithing")
}

if (production.canProduce()) {
    production.produceItem()
} else {
    println("Cannot produce item - missing requirements")
}
```

### 🔄 Integration with SuspendableScript

The skilling framework integrates seamlessly with `SuspendableScript`:

```kotlin
class SkillingScript : SuspendableScript() {
    private val production = this.skilling.production {
        itemName("Clean ranarr")
        category("Clean Herbs")
    }
    
    override suspend fun onLoop() {
        production.produceItem(
            onProgress = { message, current, total, rate, xp ->
                println("${message.message}: $current/$total")
            },
            onFinished = { totalXp ->
                println("Finished! Total XP: $totalXp")
                awaitTicks(10) // Wait before next production
            }
        )
    }
}
```

###


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kxapi.gitbook.io/kxapi/skilling/production-interface-makex.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
