Skip to reading
Action Lists & Events

Build a purchase that can fail safely

Edition 0.86.4.7

0.86.4.7 tutorial edition with new lessons for Studio 0.86.4.6 and 0.86.4.7. Earlier chapters, screenshots and registry figures retain their stated edition context.

Download PDFView PDF page
PCA 3D ADVENTURE STUDIO                                                                           Action lists and events

STUDIO 0.86.4.7 • LESSON 2 OF 4

Use a branch to decide what a player may buy and a single inventory transaction to exchange the items.

1. Describe the decision

In an action sequence, choose If Variable. Open its condition editor. Add the eligibility condition your puzzle requires, such as a game variable shop_open equal to true. Open Then for the eligible path and Else for a message explaining why the counter is closed.

2. Put the exchange in one step

Under Then, add Inventory Transaction. Use its Add Inventory and Remove Inventory rows to remove the payment item and add the purchase in the active bag. Set the item IDs and quantities. Place the receipt on the successful path after the transaction.

3. Choose what a failure does

Choose stop when later actions assume the exchange succeeded. Use recover when you want a failure message or other recovery actions. Recovery can resume the surrounding list, so place the “purchase complete” message only on a path where both changes succeeded. Continue is appropriate for an optional step that later rows can safely skip.

WHAT TO CHECK

Run three cases on a project copy. With the counter closed, the Else message should appear. With it open and payment missing, inventory should stay unchanged. With payment present, it should disappear once and the purchased item should appear once.

Related original lesson | p. 52 Tutorial edition 0.86.4.7

Page 192 of 194Permalink
Go to page