Long time ago, someone once try to build a more nice looking UI for inventory in harlowe:
I have see this, so I pasted it if you are interested it:
say, if your inventory has a structure like this : ( dm: “item names”, numbers)
(set:$inv to (dm:
'paper', 1,
'handgun',3,
'herbs', 1,
) )
Then you store description, and price for those items in another datamap like this :
(set:$iteminfo to (dm:))
(set:$iteminfo's 'paper' to (dm:
'cost',1,
'description','just a paper',
))
(set:$iteminfo's 'handgun' to (dm:
'cost',100,
'description','a string weapon',
))
(set:$iteminfo's 'herbs' to (dm:
'cost',10,
'description','a common vegetation',
))
Then the most fun part:
you can use a css to make it looks better:
<style>
table {
border-collapse: collapse;
width: 100%;
}
.color {
color: red
}
th, td {
padding: 8px;
text-align: left;
border: 1px solid #ddd;
}
tr:hover {background-color:#DC143C;}
</style>
</head>
<body>
Finally you build a chart to your inventory:
(set: $list to (datanames: $inv))
(set:$listhead to (a:'item name','number','cost','description'))
[
<!-- chart head-->
(set: $dummy to "<table>")
(set: $dummy to it + "<tr>")
(for: each _head, ...$listhead)[
(set: $dummy to it + "<td>")
(set: $dummy to it + _head)
(set: $dummy to it + "</td>")
]
(set: $dummy to it + "</tr>")
<!-- iteme names-->
(for: each _item, ...$list)[
(set: $dummy to it + "<tr><td>")
(set: $dummy to it + _item)
(set: $dummy to it + "</td>")
<!-- numbers-->
(set:$num to $inv's (_item))
(set: $dummy to it + "<td>")
(set: $dummy to it + (str:$num))
(set: $dummy to it + "</td>")
<!-- cost-->
(set:$cost to $iteminfo's (_item)'s 'cost')
(set: $dummy to it + "<td>")
(set: $dummy to it + (str:$cost))
(set: $dummy to it + "</td>")
<!-- description-->
(set:$description to $iteminfo's (_item)'s 'description')
(set: $dummy to it + "<td>")
(set: $dummy to it + $description)
(set: $dummy to it + "</td>")
]
(set: $dummy to it + "</tr>")
(set: $dummy to it + "</table>")
]}
So here it is, you’ve build your inventory system,
you can add a (print:$dummy) to show this charts