Skip to main content

Crafting

PocketPal: PRO has a simple but game-ready crafting system, inspired by World of Warcraft: Classic. It is built to be easily extendable.

It consists of 3 widgets:

  • W_CraftingMenu (main window)
  • W_CraftableItemEntry (text entry)
  • W_CraftableRequired (required item entry).

Inspect these widgets - they are thoroughly commented out and will tell you what each event/function is for.

Crafting Functions

  • InitCraftableItems(): This function will initialise craftables according to the "Unlocked Craftables" array located in the “Config” category. It will also bind to a dispatcher to listen if the user clicks on a craftable entry to respond accordingly (to show required materials, etc.)
  • CheckIfCanCraft(): This function will get crafting materials of specified item from DT_Craftables and check if the player has enough in inventory to craft the specified item.
  • TryCraftItem(): This function will first get the crafting materials of the targetItem from DT_Craftables, try to add it to the inventory, and if successful, will get the required materials and remove them. Otherwise sends UI error message.
  • RefreshRequiredCraftingMaterials(): This simple helper function will re-init crafting materials.

New Craftables

To make usage easier, there is an additional DataTable (DT_Craftables). By adding a new row to this DataTable, you can create new craftables! Ensure that the RowName & CraftableItemID are exactly the same, and the ItemID you are adding actually exists (in DT_Items).

img

important

After adding your craftable item, ensure that you add it to “UnlockedCraftables[]” array inside PC_Inventory → BPC_Inventory.