Skip to content

Commit fa4647a

Browse files
docs(stdlib): regenerate API reference (#68)
Co-authored-by: Frotty <1486037+Frotty@users.noreply.github.com>
1 parent 46f1e7b commit fa4647a

43 files changed

Lines changed: 3702 additions & 1123 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎_data/stdlib_index.json‎

Lines changed: 2739 additions & 1054 deletions
Large diffs are not rendered by default.

‎_doc/stdlib/ref/_handles/Integer.md‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ generated: true
1010
toc: sections
1111
---
1212

13+
Returns this int to the power of the argument int.
14+
A negative exponent yields 1, since the true result is not an integer.
15+
Overflow wraps silently.
16+
1317
**[Source on GitHub](https://github.com/wurstscript/WurstStdlib2/blob/master/wurst/_handles/primitives/Integer.wurst)**
1418

1519
## Extension Functions
@@ -62,14 +66,21 @@ public function int.toString() returns string
6266

6367
Returns the string representation of this int
6468

69+
### int.toStringOrdinal
70+
71+
```wurst
72+
public function int.toStringOrdinal() returns string
73+
```
74+
75+
Returns this int with its English ordinal suffix, e.g. 1 -> "1st", 2 -> "2nd", 3 -> "3rd", 4 -> "4th".
76+
Handles the 11/12/13 exceptions correctly.
77+
6578
### int.pow
6679

6780
```wurst
6881
public function int.pow(int x) returns int
6982
```
7083

71-
Returns this int to the power of the argument int
72-
7384
### int.lerp
7485

7586
```wurst

‎_doc/stdlib/ref/_handles/Real.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The arctangent function with two arguments.
2424
public function real.abs() returns real
2525
```
2626

27-
Returns the abolsute value of the given real.
27+
Returns the absolute value of the given real.
2828
This means, negative values will be return positive.
2929

3030
### real.squared

‎_doc/stdlib/ref/_handles/Rect.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,33 @@ public function rect.remove()
140140
public function rect.copy() returns rect
141141
```
142142

143+
### rect.toRegion
144+
145+
```wurst
146+
public function rect.toRegion() returns region
147+
```
148+
149+
Converts this rect to a region.
150+
WARNING: Creates a new region; caller owns it and must call .destr() to avoid a handle leak.
151+
152+
### rect.fromCenter
153+
154+
```wurst
155+
public function rect.fromCenter(real sizeX, real sizeY) returns rect
156+
```
157+
158+
Creates a rect centered at this rect's center with the given full width and height.
159+
Example: A rect at (100,100) with sizeX=20, sizeY=30 spans from (90,85) to (110,115).
160+
161+
### rect.fromCenterWithOffset
162+
163+
```wurst
164+
public function rect.fromCenterWithOffset(real sizeX, real sizeY, vec2 offset) returns rect
165+
```
166+
167+
Creates a rect centered at this rect's center plus offset, with the given full width and height.
168+
Example: A rect at (100,100) with offset (10,0), sizeX=20, sizeY=30 spans from (100,85) to (120,115).
169+
143170
### rect.setRectFromLoc
144171

145172
```wurst

‎_doc/stdlib/ref/_handles/String.md‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ public class StringLines
6161
public function stringCompare(string s1, string s2) returns int
6262
```
6363

64-
Returns an integer result based on a lexicographic string comparison of strings s1 and s2.
64+
Returns a negative number if s1 sorts before s2, a positive number if it
65+
sorts after, and 0 only if the two strings are equal.
66+
67+
Alphanumerics keep their long standing order: digits, then lowercase, then
68+
uppercase, so "Hello" sorts after "hello". Every other printable ascii
69+
character sorts after all alphanumerics, ordered by ascii code point among
70+
themselves. Bytes outside printable ascii - control characters and the
71+
individual bytes of multibyte characters - sort last, tie-broken by string
72+
hash so the result stays consistent.
6573

6674
## Extension Functions
6775

@@ -230,23 +238,23 @@ True when string contains only lowercase letters
230238
public function string.trim() returns string
231239
```
232240

233-
Returns the given string with whitespaces removed from both ends
241+
Returns the given string with whitespace (" ", \n, \t, \r) removed from both ends
234242

235243
### string.ltrim
236244

237245
```wurst
238246
public function string.ltrim() returns string
239247
```
240248

241-
Returns the given string with whitespaces removed from the left end
249+
Returns the given string with whitespace (" ", \n, \t, \r) removed from the left end
242250

243251
### string.rtrim
244252

245253
```wurst
246254
public function string.rtrim() returns string
247255
```
248256

249-
Returns the given string with whitespaces removed from the right end
257+
Returns the given string with whitespace (" ", \n, \t, \r) removed from the right end
250258

251259
### string.ltrim
252260

‎_doc/stdlib/ref/_handles/Unit.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,16 @@ public function unit.disableAbility(int abilId, boolean flag, boolean hideUI)
13861386
public function unit.disableAttack(boolean flag, boolean hideUI)
13871387
```
13881388

1389+
### unit.disableAttackEx
1390+
1391+
```wurst
1392+
public function unit.disableAttackEx(int index, bool flag)
1393+
```
1394+
1395+
Enables/disables a single weapon by index (0 = the unit's first/regular attack).
1396+
Unlike disableAttack this toggles the weapon field directly, so it can disable one
1397+
weapon on a multi-weapon unit without hiding the attack command.
1398+
13891399
### unit.disableWorkQueue
13901400

13911401
```wurst

‎_doc/stdlib/ref/closures/ClosureForGroups.md‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ toc: sections
1313
curated: /stdlib/closure_for_groups
1414
---
1515

16-
Executes the given closure for every unit in this group,
17-
removing the units from the group as processed.
18-
Return true to continue iteration, false to stop.
16+
Executes the given closure for every unit of the given type.
17+
Stops invoking the closure after *count* units. The underlying enumeration
18+
cannot be aborted, so it still visits every match.
1919

2020
**[Source on GitHub](https://github.com/wurstscript/WurstStdlib2/blob/master/wurst/closures/ClosureForGroups.wurst)**
2121

@@ -72,9 +72,6 @@ Executes the given closure for every unit of the given type.
7272
public function forUnitsOfTypeCounted(string unitname, int count, ForGroupCallback c)
7373
```
7474

75-
Executes the given closure for every unit of the given player.
76-
Cancels itself after *count* iterations
77-
7875
### forUnitsOfPlayer
7976

8077
```wurst
@@ -106,7 +103,8 @@ public function forUnitsInRectCounted(rect r, int count, ForGroupCallback c)
106103
```
107104

108105
Executes the given closure for every unit in the given rect.
109-
Cancels itself after *count* iterations
106+
Stops invoking the closure after *count* units. The underlying enumeration
107+
cannot be aborted, so it still visits every unit in the rect.
110108

111109
### forUnitsInRange
112110

@@ -131,8 +129,9 @@ Executes the given closure for every unit in range of the given position
131129
public function forUnitsInRangeCounted(vec2 pos, real radius, int count, ForGroupCallback c)
132130
```
133131

134-
Executes the given closure for every unit in range of the given position
135-
Cancels itself after *count* iterations
132+
Executes the given closure for every unit in range of the given position.
133+
Stops invoking the closure after *count* units. The underlying enumeration
134+
cannot be aborted, so it still visits every unit in range.
136135

137136
### forUnitsSelected
138137

@@ -212,7 +211,7 @@ public function forDestructablesInRange(vec2 pos, real range, ForGroupCallbackD
212211
```
213212

214213
Executes the given closure for all destructables in a rect
215-
that incompasses the circle with the range radius at the given position.
214+
that encompasses the circle with the range radius at the given position.
216215

217216
### forDestructablesInRange
218217

@@ -221,7 +220,7 @@ public function forDestructablesInRange(vec2 pos, real range, boolexpr filter, F
221220
```
222221

223222
Executes the given closure for all destructables in a rect
224-
that incompasses the circle with the range radius at the given position.
223+
that encompasses the circle with the range radius at the given position.
225224

226225
### forDestructablesInRect
227226

@@ -245,7 +244,7 @@ Executes the given closure for all destructables in the given rect
245244
public function forNearestDestructable(vec2 pos, real range, ForGroupCallbackD c)
246245
```
247246

248-
Executes the given closure for the closes destructable in the given rect.
247+
Executes the given closure for the closest destructable in the given range.
249248
If there is no destructable in range, the closure will be run with "null"
250249

251250
## Extension Functions
@@ -274,6 +273,10 @@ Executes the given closure for every unit in this group,
274273
public function group.forEachFromUntil(ForGroupCallbackUntil cb)
275274
```
276275

276+
Executes the given closure for every unit in this group,
277+
removing the units from the group as processed.
278+
Return true to continue iteration, false to stop.
279+
277280
### group.forEachInUntil
278281

279282
```wurst

‎_doc/stdlib/ref/closures/ClosureTimers.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public abstract class CallbackPeriodic
4949
**Members:**
5050

5151
- `abstract function call(thistype cb)`
52+
- `disable()`
53+
Pauses this periodic callback without destroying it. Safe to call when already disabled.
54+
- `enable()`
55+
Resumes a previously disabled periodic callback. Safe to call when already enabled.
5256

5357
### CallbackCounted
5458

@@ -61,9 +65,14 @@ public abstract class CallbackCounted
6165
- `abstract function call(thistype cb)`
6266
- `isLast() returns boolean`
6367
- `getCount() returns int`
68+
The number of this call, counting down: maxCount on the first call and
69+
1 on the last. Returns maxCount before the first call.
6470
- `progress() returns real`
65-
Returns a value between 0 and 1.
71+
Progress through the run as a value between 0 and 1.
72+
Returns 0 if the callback was started with a call count of 0.
6673
- `stop()`
74+
Stops the callback. The remaining calls are skipped and the object is
75+
destroyed on the next tick, not immediately.
6776
- `callAndCount()`
6877

6978
## Interfaces
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: SpatialIndexForUnits
3+
layout: stdlibref
4+
category: closures
5+
categoryLabel: Closures
6+
tags:
7+
- closures
8+
source: 'https://github.com/wurstscript/WurstStdlib2/blob/master/wurst/closures/SpatialIndexForUnits.wurst'
9+
generated: true
10+
toc: sections
11+
---
12+
13+
**[Source on GitHub](https://github.com/wurstscript/WurstStdlib2/blob/master/wurst/closures/SpatialIndexForUnits.wurst)**
14+
15+
## Functions
16+
17+
### unitsInRange
18+
19+
```wurst
20+
public function unitsInRange(vec2 center, real radius) returns SparseSet<unit>
21+
```
22+
23+
Returns units whose origins are within radius of center.
24+
25+
### unitsInRange
26+
27+
```wurst
28+
public function unitsInRange(vec2 center, real radius, boolean collisionFiltering) returns SparseSet<unit>
29+
```
30+
31+
Returns units in range, optionally applying collision-size filtering.
32+
33+
### unitsInBox
34+
35+
```wurst
36+
public function unitsInBox(vec2 boxMin, vec2 boxMax) returns SparseSet<unit>
37+
```
38+
39+
Returns units whose origins are inside the axis-aligned box.
40+
41+
### unitsOfPlayer
42+
43+
```wurst
44+
public function unitsOfPlayer(player owner) returns SparseSet<unit>
45+
```
46+
47+
Returns currently indexed units owned by owner.

‎_doc/stdlib/ref/data/ArrayList.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,23 @@ public function ArrayList<string>.join() returns string
197197
```
198198

199199
Joins elements from a string list into one string
200+
201+
## Constants
202+
203+
### intComparator
204+
205+
```wurst
206+
public constant Comparator<int> intComparator = (i1, i2) -> i1 < i2 ? -1 : (i1 > i2 ? 1 : 0)
207+
```
208+
209+
### realComparator
210+
211+
```wurst
212+
public constant Comparator<real> realComparator = (r1, r2) -> r1 < r2 ? -1 : (r1 > r2 ? 1 : 0)
213+
```
214+
215+
### stringComparator
216+
217+
```wurst
218+
public constant Comparator<string> stringComparator = (s1, s2) -> stringCompare(s1, s2)
219+
```

0 commit comments

Comments
 (0)