Replace the wallet with Safe and compare the work required
Use a Safe component with checked reads.
Optional extension. It is not required to complete the core path.
Goal: Use a Safe component with checked reads.
Before you start: The finished Normal wallet; work in the specified copies.
Optional extension. Finish the core path first, then return when you need this capability.
The idea you will use
Safe adds in-memory protection and checks. Reads can fail; memory protection does not by itself protect a save file.
Predict before running
If Try Get Value fails, can zero be displayed as a successful read?
Build and check
Keep the Normal exercise. Duplicate BP_MiCartera as BP_MiCarteraSafe and the widget as WBP_MiCarteraSafe. Make changes in the copies.
- In BP_MiCarteraSafe, add a Scientific Number Safe Value Component named WalletSafe. During BeginPlay, connect Make Scientific Number (Base 1000, Exponent 0) directly to New Value on Try Set Value, with WalletSafe as Target. Connect BeginPlay execution directly to Try Set Value and check Return Value with Branch; on False, connect Out Error to Print Scientific Number Error. Do not add Try Make Safe Scientific Number: New Value takes an ordinary Scientific Number and the component protects it internally. If you already added that intermediate node, remove it and reconnect both wires directly. The component is already initialized to zero before BeginPlay; here you set its initial balance to 1000.
- In WBP_MiCarteraSafe, change the Cartera variable type to BP_MiCarteraSafe Object Reference. Compile. In the Actor, change Create Widget to WBP_MiCarteraSafe and reconnect Self.
- In ActualizarSaldo, replace Normal’s Get Value with Try Get Value from WalletSafe. Add Branch. On True, format Out Value and update TXT_Saldo. On False, show Could not authenticate balance; do not replace it with zero.
- In Produce, use Try Add on WalletSafe, Amount 25. Check success/error and refresh the authenticated read.
- In Buy, use Try Spend on WalletSafe, Cost 100. This node returns whether it could spend and preserves the balance if it cannot. On False, distinguish Out Error = None (insufficient balance) from a numeric/authentication error. Do not reinitialize WalletSafe or recreate 1000 on every click.
- In the level, replace the Normal instance with the Safe one. Repeat the wallet checks from lesson 3 and pause on Try Spend to inspect the pins.
- To trigger a numeric failure, temporarily add a third button that runs Try Divide with Amount zero. It should return False/DivisionByZero, and a later read should retain the previous balance.
Check your reasoning
See the explanation
No. Report the failure and do not consume Out Value as a valid balance.
Your turn: Repeat the same purchases with Normal and Safe and identify the checked reads.
Ready to continue when: you can distinguish insufficient funds from read or operation errors.
Progress is saved only in this browser and carries over when you switch language.