You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stop after _N_ matching items have been encountered. (The word `first` is optional)
68
68
***skip _N_**_or_**after _N_**
69
-
Skip the first _N_ matching items.
70
-
69
+
Skip the first _N_ matching items.
70
+
***sort** or **sorted**
71
+
Sort items by name within each respective container. Articles "a", "an", "some" and "the" are ignored when sorting.
72
+
Containers will still be handled one at a time, and the order of the containers themselves is not affected.
73
+
***reverse** or **reversed**
74
+
Reverse the order of items within each container. If used alone, this means the last item in each container in
75
+
processed first and vice versa. If used with **sorted**, items will be handled in descending alphabetical order
76
+
rather than ascending.
77
+
Containers will still be handled one at a time, and the order of the containers themselves is not affected.
78
+
71
79
Options are applied roughly in the order listed above. You can combine **first** with **skip**:
72
80
`;foreach first 5 after 10` will match items 11 through 15.
73
81
@@ -80,6 +88,8 @@ _what_ allows you to filter the types of items `foreach` acts on. It can be one
80
88
(which includes things like palimpests and other 'alternate names' for scrolls). `;foreach` by itself will show all
81
89
the known types. `;foreach in inv` with no commands will show the types of all items it finds.
82
90
91
+
You can use `type=none` to explicitly find items that have no defined type according to Lich.
92
+
83
93
**Note:** This is only as accurate as Lich's own type data. You may be able to get more accurate type data by downloading and running the `gameobjadd` script at startup.
84
94
85
95
***noun=**_pattern_ or **n=**_pattern_
@@ -103,10 +113,11 @@ _pattern_ can be:
103
113
*`this,that`: Match any one of the options separated by commas.
104
114
*`blue sapphire,emerald,*diamond,*emerald,uncut ruby`: You can mix the above.
105
115
106
-
### Target
116
+
### Targets
117
+
118
+
_targets_ tells ;foreach where you want to look for the items. You can specify one or more _target_, separated by commas.
107
119
108
-
_target_ tells ;foreach where you want to find the items. You can specify any container exactly like you'd specify it to
109
-
a command in game, but there's also a few special options:
120
+
Each target can be the name of an actual container in game ("cloak", "my backpack", etc.), or one of the following options:
110
121
111
122
***inv** or **inventory**
112
123
Examines the contents all containers in your inventory.
@@ -124,11 +135,14 @@ a command in game, but there's also a few special options:
124
135
Examines items in your inventory, *not* their contents. Want to register everything you are wearing?
125
136
`foreach in worn; remove item;register item;wear item`
126
137
127
-
***last**
138
+
***last**or **previous**
128
139
Last is a set of items that matches whatever the last run of foreach found. You can use this to quickly undo if you
129
140
manage to flub something up, like accidentally moving all of your inventory to your locker rather than just your boxes.
130
141
131
-
If you specified a _what_ (above section), it will further restrict the list of what foreach is working on
142
+
When using **last**, the container items are reported in will be the container they started the previous run in -- not
143
+
their current location.
144
+
145
+
If you specified a _what_ (above section), it will further restrict the list of what foreach is working on.
132
146
133
147
### Commands
134
148
@@ -327,18 +341,20 @@ Depending on the level of depth you want, either just read the bold parts, just
327
341
If, after all of the above, ;foreach doesn't have status data for the container (meaning it's probably not in your inventory),
328
342
it assumes that it won't have status data for any of its contents either and exits.
329
343
330
-
4.**Item Filtering**: For each container and list of items in to_filter, items are filtered based on your criteria,
344
+
4.**Item Sorting**: If the SORTED or REVERSED options are specified, they are applied to each container inventory.
345
+
346
+
5.**Item Filtering**: For each container and list of items in to_filter, items are filtered based on your criteria,
331
347
including applying any options (e.g. `UNIQUE`, `MARKED`, `FIRST 5`). If you're filtering by status and any item is
332
348
not found in the the table, `;foreach` complains loudly and exits. This particular failure should never occur,
333
349
since of all the related checks should have happened earlier.
334
350
335
351
Any containers that have items left after the filtering phase are removed from the relevant tables.
336
352
If no remaining items exist, ;foreach exits.
337
353
338
-
5.**Snapshot**: At this point, ;foreach knows every single item and container it is going to work on. This information
354
+
6.**Snapshot**: At this point, ;foreach knows every single item and container it is going to work on. This information
339
355
is saved for later usage in `;foreach in last`, and then the execution phase begins
340
356
341
-
6.**Execution**: For each container:
357
+
7.**Execution**: For each container:
342
358
* If there are no commands, pretty-print a list of matching contents in that container.
343
359
* Otherwise, for each item in the container, for each command:
344
360
* Replace "item", "noun", "name" and "container" with the item ID, item noun, item name and container ID.
@@ -357,9 +373,25 @@ Depending on the level of depth you want, either just read the bold parts, just
357
373
would scroll by while in roundtime, or the script waiting to pause (and thus preventing it from being unpaused
358
374
until you are out of roundtime)
359
375
360
-
361
376
## Changelog
362
377
378
+
### Version 0.10 (2019-06-10)
379
+
* Foreach now reports its status in the shortcut bar in Stormfront, and can be paused, resumed, or killed from that location.
380
+
* You can now look under/behind containers instead of just in/on them.
381
+
* Legacy premium locker searching now looks ON armor stands and weapon racks rather than IN them.
382
+
(This code only triggers if LOCKER MANIFEST fails for whatever reason).
383
+
* Pattern matching is no longer case-sensitive
384
+
`;foreach q=elan*pack in pack` should now match "an Elanthian Guilds voucher pack"
385
+
* You can now `;foreach sorted ...` to iterate over items sorted by their full name within their containers.
386
+
* Articles a/an/some/the are ignored when sorting, so "some ambrominas leaf" sorts before than "a clear zircon"
387
+
* This does not affect the order containers are traversed.
388
+
* You can now `;foreach reversed ...` to iterate over items backwards within their containers.
389
+
* When combined with `sorted`, this does items in descending order.
390
+
* This does not affect the order containers are traversed.
391
+
* You can now specify multiple targets in a single `;foreach command`
392
+
Example: `;foreach gem in backpack,cloak,Wyrom disk,locker ...`
393
+
*`;foreach type=none ...` will now match items that have no explicit type defined.
394
+
363
395
### version 0.9.9 (2019-05-24)
364
396
* Add `UNMARK` shortcut for `MARK <item> REMOVE`
365
397
* Improved documentation, including updating the online documentation
0 commit comments