Line 86: |
Line 86: |
| -- * Equipment iterators. | | -- * Equipment iterators. |
| | | |
− | function Iterator.equipmentBy(context, n, pred, pre) | + | function Iterator.equipmentBy(context, n, pred, pre, empty) |
| local predKey = stringKey('pred', context, n) | | local predKey = stringKey('pred', context, n) |
| if predKey then | | if predKey then |
Line 129: |
Line 129: |
| end | | end |
| current = e._name | | current = e._name |
| + | if empty and not current then |
| + | current = empty |
| + | end |
| i = i + 1 | | i = i + 1 |
| preFlag = true | | preFlag = true |
Line 172: |
Line 175: |
| end | | end |
| end | | end |
| + | ) |
| + | end |
| + | |
| + | function Iterator.equipmentByIdWithEmptyWithHeaders(context, n) |
| + | local from = numberKey('from', context, n, 1) |
| + | local to = numberKey('to', context, n, 500) |
| + | local prevMod = 0 |
| + | return Iterator.equipmentBy( |
| + | context, n, |
| + | function(e) |
| + | return e._id >= from and e._id <= to |
| + | end, |
| + | function(e) |
| + | local currentMod = (e._id - 1) % 10 |
| + | if currentMod <= prevMod then |
| + | prevMod = currentMod |
| + | local title = string.format("No. %s - %s", U.pad(e._id - currentMod, 3, "0"), U.pad(e._id - currentMod + 9, 3, "0")) |
| + | return string.format("!#[[Equipment#%s|%s]]", title, title) |
| + | else |
| + | prevMod = currentMod |
| + | return false |
| + | end |
| + | end, |
| + | "-" |
| ) | | ) |
| end | | end |