Skip to content

Commit 019b5ef

Browse files
committed
new and improved docs
1 parent 680467e commit 019b5ef

File tree

4 files changed

+196
-156
lines changed

4 files changed

+196
-156
lines changed

_doc/stdlib/closures/execute.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Execute
3+
---
4+
5+
# Execute Package
6+
7+
The `Execute` package is designed as an easy way to reset the OP limit. The OP limit in Warcraft 3 JASS is an inherent limit of subsequent operations in a thread. If the limit is reached, execution will stop. This package provides essential tools to handle expensive computations that might otherwise crash a thread due to exceeding the operation limit.
8+
9+
## Basic Usage
10+
11+
Use `execute` to simply start a new thread, bypassing the oplimit. The execution is synchronous, meaning the code after `execute` will be executed after the code inside `execute` has been successfully executed.
12+
13+
```wurst
14+
import Execute
15+
16+
init
17+
execute() ->
18+
print("OP limit now reset")
19+
```
20+
21+
## Try Example
22+
23+
`try()` works like `execute()`, but catches errors and returns `false` if the callback fails.
24+
25+
### Return Value
26+
27+
- `true`: If the callback executes successfully.
28+
- `false`: If an error occured.
29+
30+
### Example
31+
32+
```wurst
33+
let result = try() ->
34+
print("hello")
35+
if not result
36+
print("Error occured")
37+
```
38+
39+
### executeWhile
40+
41+
```wurst
42+
executeWhile(50, () -> player.hasUnits(), () -> begin
43+
// Perform action for each iteration
44+
end)
45+
```

_doc/stdlib/execute.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Execute
3+
layout: stdlibdoc
4+
color: blue
5+
date: 2025-01-15
6+
sections:
7+
- /stdlib/closures/execute
8+
---
9+
10+
**[SOURCE ON GITHUB](https://github.com/wurstscript/WurstStdlib2/blob/master/wurst/closures/Execute.wurst)**

_doc/stdlib/intro.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ All packages in the standard library follow the [coding conventions](https://wur
4242

4343
    * *{: .fa .fa-file} [Closure Timers](stdlib/closure_timers)
4444

45+
    * *{: .fa .fa-file} [Execute](stdlib/execute)
46+
4547
### * *{: .fa .fa-folder-open} Data
4648

4749
    * *{: .fa .fa-file} [Bit Set](stdlib/bitset)

0 commit comments

Comments
 (0)