0 votes
by (2.3k points)
edited by

I'm trying to put in a removal of the inventory for later retrieval within another (later) passage, but I'm not sure how to do it. I found this guy over at:

https://github.com/ChapelR/custom-macros-for-sugarcube-2/blob/master/docs/simple-inventory.md#macro-transfer

Had some neat-looking code, but I think it's for Javascript maybe?

:: Prison
The guards frisk you and take your weapons.
<<transfer '$player' '$holding' $weaponList>>

:: Release
You've been released from prison, and your weapons are returned to you.
<<transfer '$holding' '$player' $weaponList>>

Having a bit of trouble running it as it's coming back with:

Error: macro <<transfer>> does not exist

 

1 Answer

0 votes
by (159k points)

Based on the linked documentation the <<transfer>> macro requires three arguements:

1. The name of the inventory related story variable you want to remove the item(s) from.
2. The name of the inventory related story variable you want to place the item(s) into.
3. Either the name of a item, or an array of items names, that you want to transfer.

ex. If you want to transfer the "Apple" from the $backpack to the $box you would do.

<<transfer '$backpack' '$box' 'Apple'>>

ex. If you want to transfer the "Banana" & "Peach" from the $fridge to the $lunchbox you would do.

<<transfer '$fridge' '$lunchbox' ["Banana", "Peach"]>>

 

by (2.3k points)
Alright, any good guides you recommend?
by (63.1k points)
For what? Installing the simple inventory? The process for installing all my macros and such is in the main readme: https://github.com/ChapelR/custom-macros-for-sugarcube-2/blob/master/readme.md#installation-guide
by (2.3k points)

Alright, I've installed it to the story JS.

It's struggling to display the inventory details though.

For example, I use this code to set an item in the story passage:

<<set $playerInventory.cloak = {
name: "Gun",
quantity: 1,
bullets: 8,
weight: 1.0,
description: "Gun description." }>>

I have this in the storyCaption:

<h2>Inventory:</h2>
[[Inventory Details|Inventory Details]] 
<ol>
<<for _key, _value range $playerInventory>>
   <li>_key (_value.name)</li>
<</for>>
</ol>

and this in the Inventory Details passage:

INVENTORY

<<nobr>>
<ul>
<<for _key, _value range $playerInventory>>
   <li>
   (_value.name)
   You have (_value.quantity) of these.
   Current Capacity is(_value.bullets)Rounds / Charges
   (_value.description)</li>
<</for>>
</ul>
<</nobr>>

But it doesn't display in the Inventory Details. :(

It also puts an extra line in on the storyCaption with 'inv' on it for some reason too.

Help and advice appreciated.

by (63.1k points)
My simple inventory is for managing key-style (simple) items in a list-style inventory, not generic objects with properties. While it's possible to extend my system to handle more complex objects, that isn't really the way to do it. Have you read the docs for the inventory system?
by (2.3k points)
I'm going through it now, I'm getting the hang of it, but need it to basically run about 4 or 5 array-type items for 'capture' and later retrieval.

If that's at all possible?

I've run a test on a very simple story and it works ok for that, just gotta export that to the big one.
...