Changes between Version 9 and Version 10 of Scripting/API


Ignore:
Timestamp:
Jun 22, 2025, 7:47:16 PM (2 months ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Scripting/API

    v9 v10  
    1515
    1616Once again: every operation ends with a call to `.go()`, which will actually perform the operation and return the result, if any. Don't forget it, or nothing will happen!
     17
     18== Interrupt/abort Support ==
     19
     20If your script does any iteration, it should support being interrupted by the user, in case it takes too long or enters an infinite loop. !WorldPainter cannot kill your script in such a case, so you need to support interruption explicitly, by using one of the following two methods:
     21
     22* `wp.interrupted` - this is a boolean property which you can check, and if `true`, cleanly abort your operation, cleaning up in so far as necessary.
     23* `wp.checkForInterrupt()` - this is a function you can call which does nothing as long as an interrupt has not been requested, and throws an exception if an interrupt ''has'' been requested. Use this if it is OK to just abort whatever the script is doing without doing clean-up.
     24
     25Do either of these in some inner loop, where it is guaranteed to be reached even if your code enters an infinite loop at a higher level.
     26
     27Note that any changes the script might have already made to the Dimension are not automatically rolled back. The user will have to do that by closing the script window and activating the Undo action using the toolbar button or by pressing Ctrl+Z.
    1728
    1829== Commandline Arguments ==