Twine Version: 2.6.2.0
Hello to everyone. First of all, I want to apologize for my poor English, it is not my primary language.
Using the Chapels simpleinventory macro, I created an inventory in his Dialog macro. I created two Divs that I can switch between using the button. I want to run a script when switching to one div, and execute another script when hiding it and switching to the other div. The point is that I want to make a system of combining. So I want to run code like <<transfer $backpack $combineinv “_item.name” 1>> that will flip items from my inventory to the combining inventory when I click on an item. When the player chooses two items he can combine them into one item and in case the player guessed the variation of items, a script like
<<button 'Combine'>>
<<if $backpack.hasAll('wood','stone')>>
<<pickup $backpack "stone" 2>>
<</if>>
<</button>>
was run. For example.
I have two questions.
The first is how can i make a flip between the two inventories when you click on the picture of the item.
And the second is how can i display the result of the combination dynamically.
<<set _ITEMS_PER_PAGE = 20>>
<<set _page = _page || 0>>
<<set _ba = $backpack.list>>
<div class="itemins">
<div class="inventory-change">
<<button 'Inspect'>>
<<run $('#ItemInspect').show(); $('#combinesys').hide();>>
<</button>>
<<button 'Combining'>>
<<run $('#combinesys').show(); $('#ItemInspect').hide();>>
<</button>>
</div>
<div id='ItemInspect'>
</div>
<div id='combinesys' style="display: none;">
<<include "Combinebuttonscript">>
</div>
</div>
<p align="right">
<div class="grid-container">
<<for _i = _page * _ITEMS_PER_PAGE; _i lt (_page + 1) * _ITEMS_PER_PAGE; _i++>>
<<if _i lt _ba.length>>
<<set _item = Item.get(_ba[_i])>>
<<if _item>>
<div class="grid-item" @style="'background-image:url(' + setup.itemIcons[_ba[_i]] + ')'">
<<if $backpack.count(_item.name) != 1>>
<div class="item-quantity"><<= $backpack.count(_item.name)>></div>
<</if>>
<<capture _item>><<link _item.name>>
<<if $('#combinesys').is(':visible')>>
<<transfer $backpack $combineinv "_item.name" 1>>
<</if>>
<<replace "#ItemInspect">>
<<= _item.description>><br><br>
<div class="descriptionbutton">
<<button "use">>
<<include "Usebuttonscript">>
<<run Engine.show()>>
<<dialogclose>>
<</button>>
</div>
<</replace>>
<</link>><</capture>>
</div>
<<else>>
<div class="grid-item">Error</div>
<<run console.error(`Item ID ${_ba[_i]} not found`)>>
<</if>>
<<else>>
<div class="grid-item"></div>
<</if>>
<</for>>
</div>
</p>
This is the code of my inventory
<div class="combine-container">
<<for _i = 0; _i < 2; _i++>>
<<set _item = Item.get($combineinv[_i])>>
<<if _item>>
<div class="grid-item" style="background-image: url('<<setup.itemIcons[$combineinv[_i]]>>')"></div>
<<else>>
<div class="grid-item"></div>
<</if>>
<</for>>
</div>
<br><br><br>
<<button 'Combine'>>
<</button>>
and this is the code to my combine script