@@ -181,15 +181,32 @@ app.transaction(
181
181
```
182
182
183
183
Creates a new transaction so you can group several sprite
184
- modifications in just one undo/redo operation.
184
+ modifications in just one undo/redo operation. If a string is given as
185
+ first argument, that string will be used as the label of this
186
+ undo/redo action (which can be seen in the * Edit > Undo History*
187
+ window).
185
188
186
- The function in the argument is called inside the transaction, if the
187
- function fails, the whole transaction is undone. If the function
188
- successes, the transaction is committed and then all actions will be
189
- grouped in just one undo/redo operation.
189
+ The given function is called inside the transaction, if the function
190
+ fails, the whole transaction is undone (i.e. all the steps executed so
191
+ far will be reversed). If the function successes, the transaction is
192
+ committed and then all actions will be grouped in just one undo/redo
193
+ operation.
190
194
191
- If a string is given as first argument, that string will be used as a
192
- label for the undo/redo action.
195
+ You can cancel/reverse/cause an explicit failure of the transaction
196
+ calling the ` error() ` Lua function, e.g:
197
+
198
+ ``` lua
199
+ app .transaction (
200
+ function ()
201
+ ...
202
+ if something_is_wrong then
203
+ error () -- this stops the function and doesn't continue with the
204
+ -- following lines / the actions so far will be reversed
205
+ -- automatically leaving the sprite intact
206
+ end
207
+ ...
208
+ end )
209
+ ```
193
210
194
211
## app.command
195
212
0 commit comments