blob: d29b1e0adb9e017615b37762e4c2f08cd4d0f357 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<script lang="ts">
import Item from './Item.svelte'
export let items
export let name = ''
export let pack = ''
export let groupLimit = 9
if (name === 'inventory')
// in the inventory, the first 9 items are the hotbar and should be at the end
items = items.slice(9).concat(items.slice(0, 9))
// each item group has 9 items
let itemGroups = []
$: {
itemGroups = []
for (let i = 0; i < items.length; i += groupLimit) {
itemGroups.push(items.slice(i, i + groupLimit))
}
}
</script>
<div class:inventory-container-{name}={name !== ''}>
{#each itemGroups as itemGroup}
<div>
{#each itemGroup as item}
<Item {item} {pack} isslot />
{/each}
</div>
{/each}
</div>
|