Skip to content

Instantly share code, notes, and snippets.

@egocarib
Created August 11, 2019 19:24
Show Gist options
  • Save egocarib/806436f21aacfd7f77740281e061d34d to your computer and use it in GitHub Desktop.
Save egocarib/806436f21aacfd7f77740281e061d34d to your computer and use it in GitHub Desktop.
qud character inventory module
character inventory module
==========================
Requirements: allow specifying an item list, quantity for each item, and whether each item is equipped. Then parse those items/details and output the HTML.
For example, the module call might look like this:
{{#invoke:Inventory | FormatInventory | powered exoskeleton~1~yes`overloaded laser pistol~2~yes`plastifier jerkin~1~no }}
Maybe there's a nicer way to format the input string instead of using ~ and ` delimiters, but I'm not sure. Or maybe it could be split into two modules (one for the wrapper HTML, and one for individual items). Feel free to do whatever makes the most sense!
if only carried items, should look like this:
=============================================
<div class="mw-collapsible mw-collapsed" id="mw-customcollapsible-qud-inventory">
<div class="mw-collapsible-content qud-inv-content-itemlist" style="display:none;">
<div class="qud-inv-group qud-carried">
<div class="qud-inventory-item">{{favilink|powered exoskeleton}} <span class="qud-item-qty">x2</span></div>
<div class="qud-inventory-item">{{favilink|overloaded laser pistol}} <span class="qud-item-qty">x2</span></div>
<div class="qud-inventory-item">{{favilink|ulnar stimulators}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|polyhedral rings}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|life loop}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|plastifer sneakers}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|cybernetics credit wedge}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|plastifer jerkin}} <span class="qud-item-qty">x1</span></div>
</div>
</div>
</div>
if equipped & carried items, should look like this:
===================================================
<div class="mw-collapsible mw-collapsed" id="mw-customcollapsible-qud-inventory">
<div class="mw-collapsible-content qud-inv-content-itemlist" style="display:none;">
<div class="qud-inv-group qud-equipped">
<div class="qud-equipped-title">Equipped</div>
<div class="qud-inventory-item">{{favilink|powered exoskeleton}} <span class="qud-item-qty">x2</span></div>
<div class="qud-inventory-item">{{favilink|overloaded laser pistol}} <span class="qud-item-qty">x2</span></div>
<div class="qud-inventory-item">{{favilink|ulnar stimulators}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|polyhedral rings}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|life loop}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|plastifer sneakers}} <span class="qud-item-qty">x1</span></div>
</div>
<div class="qud-inv-group qud-carried">
<div class="qud-equipped-title">Carried</div>
<div class="qud-inventory-item">{{favilink|cybernetics credit wedge}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|plastifer jerkin}} <span class="qud-item-qty">x1</span></div>
</div>
</div>
</div>
if only equipped items, should look like this:
==============================================
<div class="mw-collapsible mw-collapsed" id="mw-customcollapsible-qud-inventory">
<div class="mw-collapsible-content qud-inv-content-itemlist" style="display:none;">
<div class="qud-inv-group qud-equipped">
<div class="qud-equipped-title">Equipped</div>
<div class="qud-inventory-item">{{favilink|powered exoskeleton}} <span class="qud-item-qty">x2</span></div>
<div class="qud-inventory-item">{{favilink|overloaded laser pistol}} <span class="qud-item-qty">x2</span></div>
<div class="qud-inventory-item">{{favilink|ulnar stimulators}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|polyhedral rings}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|life loop}} <span class="qud-item-qty">x1</span></div>
<div class="qud-inventory-item">{{favilink|plastifer sneakers}} <span class="qud-item-qty">x1</span></div>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment